Skip to content

Commit

Permalink
Fix tests expecting a DeprecationWarning that is not raised
Browse files Browse the repository at this point in the history
  • Loading branch information
Jorewin committed Feb 19, 2024
1 parent 9093962 commit 3523b7b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 13 deletions.
2 changes: 0 additions & 2 deletions pandas/tests/io/parser/common/test_inf.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ def test_read_csv_with_use_inf_as_na(all_parsers):
data = "1.0\nNaN\n3.0"
msg = "use_inf_as_na option is deprecated"
warn = FutureWarning
if parser.engine == "pyarrow":
warn = (FutureWarning, DeprecationWarning)

with tm.assert_produces_warning(warn, match=msg, check_stacklevel=False):
with option_context("use_inf_as_na", True):
Expand Down
2 changes: 0 additions & 2 deletions pandas/tests/io/parser/common/test_read_errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ def test_warn_bad_lines(all_parsers):
expected_warning = ParserWarning
if parser.engine == "pyarrow":
match_msg = "Expected 1 columns, but found 3: 1,2,3"
expected_warning = (ParserWarning, DeprecationWarning)

with tm.assert_produces_warning(
expected_warning, match=match_msg, check_stacklevel=False
Expand Down Expand Up @@ -311,7 +310,6 @@ def test_on_bad_lines_warn_correct_formatting(all_parsers):
expected_warning = ParserWarning
if parser.engine == "pyarrow":
match_msg = "Expected 2 columns, but found 3: a,b,c"
expected_warning = (ParserWarning, DeprecationWarning)

with tm.assert_produces_warning(
expected_warning, match=match_msg, check_stacklevel=False
Expand Down
14 changes: 7 additions & 7 deletions pandas/tests/io/parser/test_parse_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def test_multiple_date_col(all_parsers, keep_date_col, request):
"names": ["X0", "X1", "X2", "X3", "X4", "X5", "X6", "X7", "X8"],
}
with tm.assert_produces_warning(
(DeprecationWarning, FutureWarning), match=depr_msg, check_stacklevel=False
FutureWarning, match=depr_msg, check_stacklevel=False
):
result = parser.read_csv(StringIO(data), **kwds)

Expand Down Expand Up @@ -724,7 +724,7 @@ def test_multiple_date_col_name_collision(all_parsers, data, parse_dates, msg):
)
with pytest.raises(ValueError, match=msg):
with tm.assert_produces_warning(
(FutureWarning, DeprecationWarning), match=depr_msg, check_stacklevel=False
FutureWarning, match=depr_msg, check_stacklevel=False
):
parser.read_csv(StringIO(data), parse_dates=parse_dates)

Expand Down Expand Up @@ -1248,14 +1248,14 @@ def test_multiple_date_col_named_index_compat(all_parsers):
"Support for nested sequences for 'parse_dates' in pd.read_csv is deprecated"
)
with tm.assert_produces_warning(
(FutureWarning, DeprecationWarning), match=depr_msg, check_stacklevel=False
FutureWarning, match=depr_msg, check_stacklevel=False
):
with_indices = parser.read_csv(
StringIO(data), parse_dates={"nominal": [1, 2]}, index_col="nominal"
)

with tm.assert_produces_warning(
(FutureWarning, DeprecationWarning), match=depr_msg, check_stacklevel=False
FutureWarning, match=depr_msg, check_stacklevel=False
):
with_names = parser.read_csv(
StringIO(data),
Expand All @@ -1280,13 +1280,13 @@ def test_multiple_date_col_multiple_index_compat(all_parsers):
"Support for nested sequences for 'parse_dates' in pd.read_csv is deprecated"
)
with tm.assert_produces_warning(
(FutureWarning, DeprecationWarning), match=depr_msg, check_stacklevel=False
FutureWarning, match=depr_msg, check_stacklevel=False
):
result = parser.read_csv(
StringIO(data), index_col=["nominal", "ID"], parse_dates={"nominal": [1, 2]}
)
with tm.assert_produces_warning(
(FutureWarning, DeprecationWarning), match=depr_msg, check_stacklevel=False
FutureWarning, match=depr_msg, check_stacklevel=False
):
expected = parser.read_csv(StringIO(data), parse_dates={"nominal": [1, 2]})

Expand Down Expand Up @@ -2267,7 +2267,7 @@ def test_parse_dates_dict_format_two_columns(all_parsers, key, parse_dates):
"Support for nested sequences for 'parse_dates' in pd.read_csv is deprecated"
)
with tm.assert_produces_warning(
(FutureWarning, DeprecationWarning), match=depr_msg, check_stacklevel=False
FutureWarning, match=depr_msg, check_stacklevel=False
):
result = parser.read_csv(
StringIO(data), date_format={key: "%d- %m-%Y"}, parse_dates=parse_dates
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/io/parser/usecols/test_parse_dates.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def test_usecols_with_parse_dates4(all_parsers):
"Support for nested sequences for 'parse_dates' in pd.read_csv is deprecated"
)
with tm.assert_produces_warning(
(FutureWarning, DeprecationWarning), match=depr_msg, check_stacklevel=False
FutureWarning, match=depr_msg, check_stacklevel=False
):
result = parser.read_csv(
StringIO(data),
Expand Down Expand Up @@ -186,7 +186,7 @@ def test_usecols_with_parse_dates_and_names(all_parsers, usecols, names, request
"Support for nested sequences for 'parse_dates' in pd.read_csv is deprecated"
)
with tm.assert_produces_warning(
(FutureWarning, DeprecationWarning), match=depr_msg, check_stacklevel=False
FutureWarning, match=depr_msg, check_stacklevel=False
):
result = parser.read_csv(
StringIO(s), names=names, parse_dates=parse_dates, usecols=usecols
Expand Down

0 comments on commit 3523b7b

Please sign in to comment.