Skip to content

Conversation

@mgorny
Copy link
Contributor

@mgorny mgorny commented Jan 20, 2024

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.

f"future version, please use '{freq_depr.upper()[1:]}' instead."

with pytest.raises(FutureWarning, match=depr_msg):
with pytest.warns(FutureWarning, match=depr_msg):
Copy link
Member

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@mroeschke mroeschke added the Testing pandas testing functions or related to the test suite label Jan 23, 2024
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.
@mroeschke
Copy link
Member

pre-commit.ci autofix

@mroeschke mroeschke added this to the 3.0 milestone Jan 23, 2024
@mroeschke mroeschke merged commit 85b7445 into pandas-dev:main Jan 23, 2024
@mroeschke
Copy link
Member

Thanks @mgorny

@mgorny
Copy link
Contributor Author

mgorny commented Jan 23, 2024

Thanks! And sorry for not running pre-commit in the morning, as I've updated the PR just before going out.

pmhatre1 pushed a commit to pmhatre1/pandas-pmhatre1 that referenced this pull request May 7, 2024
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Testing pandas testing functions or related to the test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CLN: Use assert_produces_warning instead of pytest.raises to show FutureWarning

2 participants