-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Add docs on pytest.warns(None) deprecation #9495
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
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 @olgarithms!
Still a few last minutes adjustments left to do, please take a look. 👍
doc/en/how-to/capture-warnings.rst
Outdated
|
||
with warnings.catch_warnings(): | ||
warnings.simplefilter("ignore") | ||
|
||
Recording warnings |
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.
Recording warnings | |
.. _recwarn: | |
Recording warnings |
doc/en/how-to/capture-warnings.rst
Outdated
@@ -300,6 +300,32 @@ filter at the end of the test, so no global state is leaked. | |||
|
|||
.. _recwarn: |
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.
This is a cross-reference label referring to the Recording warnings
section, so it should be kept close to it.
We should also create a new cross reference label here that can be used instead of the full URL in the changelog:
.. _recwarn: | |
.. _warns-use-cases: |
doc/en/deprecations.rst
Outdated
or ``pytest.warns(Warning)``. | ||
|
||
See https://docs.pytest.org/en/latest/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests for use cases. |
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.
See https://docs.pytest.org/en/latest/how-to/capture-warnings.html#additional-use-cases-of-warnings-in-tests for use cases. | |
See :ref:`warns-use-cases` for examples. |
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 @olgarithms!
Thanks @olgarithms! This is a really nice solution for a very long discussion thread 💖 |
Thank you all for your guidance and making this far less intimidating than it was! |
Closes #9404.
I added more context on the deprecation doc, but I have been wondering whether it would be useful to have these example on the main doc of
pytest.warns()
, as people might not reach the first one.Thoughts?