@@ -104,7 +104,7 @@ def test_fn(my_input: Any, _df: DataFrameType) -> DataFrameType:
104104 with pytest .raises (AssertionError ) as excinfo :
105105 test_fn ("foo" , _df = df )
106106
107- assert "DataFrame contained unexpected column(s): Price" in str (excinfo .value )
107+ assert "DataFrame in parameter '_df' contained unexpected column(s): Price" in str (excinfo .value )
108108
109109
110110def test_correct_input_with_columns_and_dtypes_pandas (basic_pandas_df : pd .DataFrame ) -> None :
@@ -131,7 +131,7 @@ def test_fn(my_input: Any) -> Any:
131131 with pytest .raises (AssertionError ) as excinfo :
132132 test_fn (basic_pandas_df )
133133
134- assert "Column Price has wrong dtype. Was int64, expected float64" in str (excinfo .value )
134+ assert "Column Price in parameter 'my_input' has wrong dtype. Was int64, expected float64" in str (excinfo .value )
135135
136136
137137def test_dtype_mismatch_polars (basic_polars_df : pl .DataFrame ) -> None :
@@ -142,7 +142,7 @@ def test_fn(my_input: Any) -> Any:
142142 with pytest .raises (AssertionError ) as excinfo :
143143 test_fn (basic_polars_df )
144144
145- assert "Column Price has wrong dtype. Was Int64, expected Float64" in str (excinfo .value )
145+ assert "Column Price in parameter 'my_input' has wrong dtype. Was Int64, expected Float64" in str (excinfo .value )
146146
147147
148148@pytest .mark .parametrize (("df" ), [pd .DataFrame (cars ), pl .DataFrame (cars )])
@@ -153,7 +153,7 @@ def test_fn(my_input: Any) -> Any:
153153
154154 with pytest .raises (AssertionError ) as excinfo :
155155 test_fn (df [["Brand" ]])
156- assert "Missing columns: ['Price']. Got columns: ['Brand']" in str (excinfo .value )
156+ assert "Missing columns: ['Price'] in parameter 'my_input' . Got columns: ['Brand']" in str (excinfo .value )
157157
158158
159159@pytest .mark .parametrize (("df" ), [pd .DataFrame (cars ), pl .DataFrame (cars )])
@@ -164,7 +164,7 @@ def test_fn(my_input: Any) -> Any:
164164
165165 with pytest .raises (AssertionError ) as excinfo :
166166 test_fn (df [["Brand" ]])
167- assert "Missing columns: ['Price', 'Extra']. Got columns: ['Brand']" in str (excinfo .value )
167+ assert "Missing columns: ['Price', 'Extra'] in parameter 'my_input' . Got columns: ['Brand']" in str (excinfo .value )
168168
169169
170170@pytest .mark .parametrize (
@@ -254,7 +254,7 @@ def test_fn(my_input: Any) -> Any:
254254 with pytest .raises (AssertionError ) as excinfo :
255255 test_fn (df )
256256
257- assert "DataFrame contained unexpected column(s): Price" in str (excinfo .value )
257+ assert "DataFrame in parameter 'my_input' contained unexpected column(s): Price" in str (excinfo .value )
258258
259259
260260def test_regex_column_with_dtype_pandas (basic_pandas_df : pd .DataFrame ) -> None :
@@ -287,7 +287,7 @@ def test_fn(my_input: Any) -> Any:
287287 with pytest .raises (AssertionError ) as excinfo :
288288 test_fn (df )
289289
290- assert "Column Price_2 has wrong dtype. Was float64, expected int64" in str (excinfo .value )
290+ assert "Column Price_2 in parameter 'my_input' has wrong dtype. Was float64, expected int64" in str (excinfo .value )
291291
292292
293293def test_regex_column_with_dtype_polars (basic_polars_df : pl .DataFrame ) -> None :
@@ -303,3 +303,22 @@ def test_fn(my_input: Any) -> Any:
303303 result = test_fn (df )
304304 assert "Price_1" in result .columns
305305 assert "Price_2" in result .columns
306+
307+
308+ @pytest .mark .parametrize (
309+ ("basic_df,extended_df" ),
310+ [(pd .DataFrame (cars ), pd .DataFrame (extended_cars )), (pl .DataFrame (cars ), pl .DataFrame (extended_cars ))],
311+ )
312+ def test_multiple_parameters_error_identification (basic_df : DataFrameType , extended_df : DataFrameType ) -> None :
313+ """Test that we can identify which parameter has the issue when multiple dataframes are used."""
314+
315+ @df_in (name = "cars" , columns = ["Brand" , "Price" ], strict = True )
316+ @df_in (name = "ext_cars" , columns = ["Brand" , "Price" , "Year" , "NonExistent" ], strict = True )
317+ def test_fn (cars : DataFrameType , ext_cars : DataFrameType ) -> int :
318+ return len (cars ) + len (ext_cars )
319+
320+ # Test missing column in second parameter
321+ with pytest .raises (AssertionError ) as excinfo :
322+ test_fn (cars = basic_df , ext_cars = extended_df )
323+
324+ assert "Missing columns: ['NonExistent'] in parameter 'ext_cars'" in str (excinfo .value )
0 commit comments