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
MAINT: Replace use of pytest.warns(None)
with warnings.catch_warnings
#15192
MAINT: Replace use of pytest.warns(None)
with warnings.catch_warnings
#15192
Conversation
…ngs`. The use of `pytest.warns(None)` is deprecated in pytest 7.0.0. The alternative suggested by the deprecation warning, `pytest.warns()`, does not match the old behavior. In fact, `pytest.warns()` is intended specifically to raise an error if the code in the context does not raise the given warning, and in pytest 7.0.0rc1, the default warning used by `pytest.warns()` is the generic `Warning` class. This issue is discussed in the following pytest issues: * pytest-dev/pytest#9002 * pytest-dev/pytest#9386 There, the recommended alternative is to use `warnings.catch_warnings`. That is the change made here. Closes scipygh-15186
This fixes the last pytest-related failure in the Azure scipy.scipy (Main prerelease_deps_coverage_64bit_blas) check that I described in #15176 (comment). There is a new failure in that check that is unrelated to this pull request. That failure is fixed by #15194. |
Note: I was a little confused by one of the error message I looked at the docs for the everything else in this looks fine. |
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.
Thanks @WarrenWeckesser. Let me just merge this to get rid of the warning. I'll comment on the related issue.
@rlucas7 wrote
Thanks--yeah, I'm aware of that, it is an old problem. I don't know if the lack of thread safety for |
The use of
pytest.warns(None)
is deprecated in pytest 7.0.0.The alternative suggested by the deprecation warning,
pytest.warns()
,does not match the old behavior. In fact,
pytest.warns()
is intendedspecifically to raise an error if the code in the context does not raise
the given warning, and in pytest 7.0.0rc1, the default warning used by
pytest.warns()
is the genericWarning
class.This issue is discussed in the following pytest issues:
There, the recommended alternative is to use
warnings.catch_warnings
.That is the change made here.
Closes gh-15186