-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
TST: test for warnings using pytest.warns() #56974
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -194,7 +194,7 @@ def test_to_offset_lowercase_frequency_deprecated(freq_depr): | |||
depr_msg = f"'{freq_depr[1:]}' is deprecated and will be removed in a " | |||
f"future version, please use '{freq_depr.upper()[1:]}' instead." | |||
|
|||
with pytest.raises(FutureWarning, match=depr_msg): | |||
with pytest.warns(FutureWarning, match=depr_msg): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use tm.assert_produces_warning
(and below)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Fix tests that used `pytest.raises()` to check for warnings, to use `tm.assert_produces_warning()` 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.
pre-commit.ci autofix |
for more information, see https://pre-commit.ci
Thanks @mgorny |
Thanks! And sorry for not running pre-commit in the morning, as I've updated the PR just before going out. |
* TST: test for warnings using tm.assert_produces_warning() Fix tests that used `pytest.raises()` to check for warnings, to use `tm.assert_produces_warning()` 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. * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Fix tests that used
pytest.raises()
to check for warnings, to usepytest.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.doc/source/whatsnew/vX.X.X.rst
file if fixing a bug or adding a new feature.