Add docs on pytest.warns(None) deprecation#9495
Merged
olgarithms merged 4 commits intopytest-dev:mainfrom Jan 13, 2022
olgarithms:does-not-warn
Merged
Add docs on pytest.warns(None) deprecation#9495olgarithms merged 4 commits intopytest-dev:mainfrom olgarithms:does-not-warn
olgarithms merged 4 commits intopytest-dev:mainfrom
olgarithms:does-not-warn
Conversation
nicoddemus
reviewed
Jan 10, 2022
nicoddemus
requested changes
Jan 13, 2022
Member
nicoddemus
left a comment
There was a problem hiding this comment.
Thanks @olgarithms!
Still a few last minutes adjustments left to do, please take a look. 👍
| with warnings.catch_warnings(): | ||
| warnings.simplefilter("ignore") | ||
|
|
||
| Recording warnings |
Member
There was a problem hiding this comment.
Suggested change
| Recording warnings | |
| .. _recwarn: | |
| Recording warnings |
| @@ -300,6 +300,32 @@ filter at the end of the test, so no global state is leaked. | |||
|
|
|||
| .. _recwarn: | |||
Member
There was a problem hiding this comment.
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:
Suggested change
| .. _recwarn: | |
| .. _warns-use-cases: |
doc/en/deprecations.rst
Outdated
| Its correct usage was checking that the code emits at least one warning of any type - like ``pytest.warns()`` | ||
| 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. |
Member
There was a problem hiding this comment.
Suggested change
| 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. |
Member
|
Thanks @olgarithms! This is a really nice solution for a very long discussion thread 💖 |
Contributor
Author
|
Thank you all for your guidance and making this far less intimidating than it was! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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?