Skip to content
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

Add docs on pytest.warns(None) deprecation #9495

Merged
merged 4 commits into from
Jan 13, 2022
Merged

Add docs on pytest.warns(None) deprecation #9495

merged 4 commits into from
Jan 13, 2022

Conversation

olgarithms
Copy link
Contributor

@olgarithms olgarithms commented Jan 9, 2022

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?

@olgarithms olgarithms marked this pull request as ready for review January 9, 2022 22:15
doc/en/deprecations.rst Outdated Show resolved Hide resolved
doc/en/deprecations.rst Outdated Show resolved Hide resolved
doc/en/deprecations.rst Outdated Show resolved Hide resolved
doc/en/deprecations.rst Outdated Show resolved Hide resolved
doc/en/deprecations.rst Outdated Show resolved Hide resolved
@The-Compiler The-Compiler added the needs backport applied to PRs, indicates that it should be ported to the current bug-fix branch label Jan 11, 2022
Copy link
Member

@nicoddemus nicoddemus left a 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. 👍


with warnings.catch_warnings():
warnings.simplefilter("ignore")

Recording warnings
Copy link
Member

Choose a reason for hiding this comment

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

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:
Copy link
Member

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:

Suggested change
.. _recwarn:
.. _warns-use-cases:

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.
Copy link
Member

Choose a reason for hiding this comment

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

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.

src/_pytest/deprecated.py Outdated Show resolved Hide resolved
testing/deprecated_test.py Outdated Show resolved Hide resolved
Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

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

Thanks @olgarithms!

@olgarithms olgarithms enabled auto-merge (squash) January 13, 2022 18:18
@olgarithms olgarithms merged commit 2ad1b58 into pytest-dev:main Jan 13, 2022
@olgarithms olgarithms deleted the does-not-warn branch January 13, 2022 18:33
@Zac-HD
Copy link
Member

Zac-HD commented Jan 13, 2022

Thanks @olgarithms! This is a really nice solution for a very long discussion thread 💖

@olgarithms
Copy link
Contributor Author

Thank you all for your guidance and making this far less intimidating than it was!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs backport applied to PRs, indicates that it should be ported to the current bug-fix branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Context manager to ensure no warnings are issued
4 participants