Skip to content

Commit 625ecae

Browse files
committed
TST: test for warnings using pytest.warns()
Fix tests that used `pytest.raises()` to check for warnings, to use `pytest.warns()` instead. This is more correct, and it fixes running the test suite without `-Werror`. This is how Gentoo runs it, to avoid sudden test failures due to new deprecation warnings from upgraded dependencies.
1 parent 696d78c commit 625ecae

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

pandas/tests/io/xml/test_xml.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1369,7 +1369,7 @@ def test_empty_stylesheet(val):
13691369
)
13701370
kml = os.path.join("data", "xml", "cta_rail_lines.kml")
13711371

1372-
with pytest.raises(FutureWarning, match=msg):
1372+
with pytest.warns(FutureWarning, match=msg):
13731373
read_xml(kml, stylesheet=val)
13741374

13751375

pandas/tests/tslibs/test_to_offset.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def test_to_offset_lowercase_frequency_deprecated(freq_depr):
194194
depr_msg = f"'{freq_depr[1:]}' is deprecated and will be removed in a "
195195
f"future version, please use '{freq_depr.upper()[1:]}' instead."
196196

197-
with pytest.raises(FutureWarning, match=depr_msg):
197+
with pytest.warns(FutureWarning, match=depr_msg):
198198
to_offset(freq_depr)
199199

200200

@@ -214,5 +214,5 @@ def test_to_offset_uppercase_frequency_deprecated(freq_depr):
214214
depr_msg = f"'{freq_depr[1:]}' is deprecated and will be removed in a "
215215
f"future version, please use '{freq_depr.lower()[1:]}' instead."
216216

217-
with pytest.raises(FutureWarning, match=depr_msg):
217+
with pytest.warns(FutureWarning, match=depr_msg):
218218
to_offset(freq_depr)

0 commit comments

Comments
 (0)