Skip to content

Commit fb5d704

Browse files
committed
No_ warning test case added
1 parent 4e5d063 commit fb5d704

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

tests/nominal/test_OneHotEncodingTransformer.py

+8-8
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ def test_fields_with_over_100_levels_error(self, library):
165165
"library",
166166
["pandas", "polars"],
167167
)
168-
def test_fit_no_warning_if_all_wanted_values_present(self, library):
168+
def test_fit_no_warning_if_all_wanted_values_present(self, library, recwarn):
169169
"""Test that OneHotEncodingTransformer.fit does NOT raise a warning when all levels in wanted_levels are present in the data."""
170170
df = d.create_df_1(library=library)
171171

@@ -174,9 +174,10 @@ def test_fit_no_warning_if_all_wanted_values_present(self, library):
174174
wanted_values={"b": ["a", "b", "c", "d", "e", "f"]},
175175
)
176176

177-
with pytest.warns(None) as warnings:
178-
transformer.fit(df)
179-
assert len(warnings) == 0
177+
transformer.fit(df)
178+
assert (
179+
len(recwarn) == 0
180+
), "OneHotEncodingTransformer.fit is raising unexpected warnings"
180181

181182

182183
class TestTransform(
@@ -501,7 +502,7 @@ def test_transform_output_with_wanted_values_arg(self, library):
501502
"library",
502503
["pandas", "polars"],
503504
)
504-
def test_transform_no_warning_if_all_wanted_values_present(self, library):
505+
def test_transform_no_warning_if_all_wanted_values_present(self, library, recwarn):
505506
"""Test that OneHotEncodingTransformer.transform does NOT raise a warning when all levels in wanted_levels are present in the data."""
506507
df_train = d.create_df_8(library=library)
507508
df_test = d.create_df_7(library=library)
@@ -511,9 +512,8 @@ def test_transform_no_warning_if_all_wanted_values_present(self, library):
511512
wanted_values={"b": ["z", "y", "x"]},
512513
)
513514
transformer.fit(df_train)
515+
transformer.transform(df_test)
514516

515-
with pytest.warns(None) as warnings:
516-
transformer.transform(df_test)
517517
assert (
518-
len(warnings) == 0
518+
len(recwarn) == 0
519519
), "OneHotEncodingTransformer.transform is raising unexpected warnings"

0 commit comments

Comments
 (0)