-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
py.test ignores warnings.simplefilter #1043
Comments
you are not at all using the pytest integration did ypu perhaps mean to do a: from warnings import warn, simplefilter
import pytest
class MyWarning(UserWarning):
pass
def warn_the_user(ind):
warn("Iteration # " + str(ind), MyWarning)
return ind
@pytest.mark.parametrize('ind', range(10))
def test_warn_the_user(ind):
with pytest.warns(MyWarning):
warn_the_user(ind) note that we discovered a bug in 2.8.0 wrt warnings, so you might need to try the 2.7 series until 2.8.1 is released see #1041 for details |
I'm more concerned that pytest seems to be overriding my simplefilter. Does pytest ignore the usual Python warnings.warn function by default? |
xref: #2452 |
I have a parametrized test that should emit a warning under certain conditions. After setting simplefilter('always'), py.test still only sees the first instance of the warning. Executing the same test in the interactive interpreter (as part of a for loop) correctly warns the user each time.
In the following simple example, for whatever reason, py.test doesn't capture any of the warnings at all.
$ py.test pytests_warning.py
============================= test session starts ==============================
platform darwin -- Python 3.4.3 -- py-1.4.30 -- pytest-2.7.2
rootdir: ~, inifile:
collected 10 items
pytests_warning.py ..........
========================== 10 passed in 0.01 seconds ===========================
The text was updated successfully, but these errors were encountered: