-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Closed
Labels
plugin: xdistrelated to the xdist external pluginrelated to the xdist external plugintopic: reportingrelated to terminal output and user-facing messages and errorsrelated to terminal output and user-facing messages and errorstype: enhancementnew feature or API change, should be merged into features branchnew feature or API change, should be merged into features branch
Description
Let's say that we have the following piece of code under test:
import warnings
import pytest
def foo():
warnings.warn("bar")
def test_foo():
with pytest.warns(UserWarning):
foo()This test will pass, and no warning will be visible in pytest's output because stdout is suppressed when a test passes.
Now we change the function under test:
def foo():
warnings.warn("bar")
warnings.warn("baz", DeprecationWarning)The test will still pass, and the newly introduced deprecationwarning will be hidden from pytest's output.
I now have to run py.test with the -s argument to make sure I don't miss these things, but this also shows the UserWarning that I am asserting, which is messing up pytest's output!
There are two ways to resolve, in my humble opinion:
- a command line option to cause tests to fail in case of warnings that haven't been caught with
pytest.warns - a command line option to show stdout of tests in case of warnings that haven't been caught with
pytest.warns
Is there already a way (or a plugin) to configure pytest as desired? Or does it require new development effort? Would like to hear your thoughts on the matter. Thanks for your time. :)
Metadata
Metadata
Assignees
Labels
plugin: xdistrelated to the xdist external pluginrelated to the xdist external plugintopic: reportingrelated to terminal output and user-facing messages and errorsrelated to terminal output and user-facing messages and errorstype: enhancementnew feature or API change, should be merged into features branchnew feature or API change, should be merged into features branch