We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
This is probably related to #1043, but that was reported before the pytest_warnings plugin was merged into pytest proper.
What I'm seeing is a warning recorded for every realization of a parameterized fixture instead of only one.
Now given this mwe.py:
import warnings import pytest import pprint @pytest.fixture(params=[1,2,3]) def fixture(request): return request.param def test_me(fixture): if fixture < 2: pprint.pprint(warnings.filters) warnings.warn('some text', DeprecationWarning) if __name__ == '__main__': for i in range(1,4): test_me(i)
I expected pytest -s -W once::DeprecationWarning mwe.py to print exactly one notice for the warning. I get all three, however:
pytest -s -W once::DeprecationWarning mwe.py
============================= test session starts ============================= platform linux -- Python 3.5.3, pytest-3.1.3, py-1.4.34, pluggy-0.4.0 rootdir: /tmp, inifile: collected 3 items mwe.py [('once', re.compile('', re.IGNORECASE), <class 'DeprecationWarning'>, re.compile(''), 0), ('ignore', None, <class 'DeprecationWarning'>, None, 0), ('ignore', None, <class 'PendingDeprecationWarning'>, None, 0), ('ignore', None, <class 'ImportWarning'>, None, 0), ('ignore', None, <class 'BytesWarning'>, None, 0), ('ignore', None, <class 'ResourceWarning'>, None, 0), ('ignore', re.compile('', re.IGNORECASE), <class 'pkg_resources.PEP440Warning'>, re.compile(''), 0)] ... ============================== warnings summary =============================== mwe.py::test_me[1] /tmp/mwe.py:12: DeprecationWarning: some text warnings.warn('some text', DeprecationWarning) mwe.py::test_me[2] /tmp/mwe.py:12: DeprecationWarning: some text warnings.warn('some text', DeprecationWarning) mwe.py::test_me[3] /tmp/mwe.py:12: DeprecationWarning: some text warnings.warn('some text', DeprecationWarning) -- Docs: http://doc.pytest.org/en/latest/warnings.html ==================== 3 passed, 3 warnings in 0.01 seconds =====================
Running python -W once::DeprecationWarning mwe.py shows what I was expecting:
python -W once::DeprecationWarning mwe.py
[('once', re.compile('', re.IGNORECASE), <class 'DeprecationWarning'>, re.compile(''), 0), ('ignore', None, <class 'DeprecationWarning'>, None, 0), ('ignore', None, <class 'PendingDeprecationWarning'>, None, 0), ('ignore', None, <class 'ImportWarning'>, None, 0), ('ignore', None, <class 'BytesWarning'>, None, 0), ('ignore', None, <class 'ResourceWarning'>, None, 0)] mwe.py:12: DeprecationWarning: some text warnings.warn('some text', DeprecationWarning)
edit: improved formatting
The text was updated successfully, but these errors were encountered:
Thanks @renemilk for the report!
Sorry, something went wrong.
@asottile - I would expect #4104 to have fixed this, but I just reproduced it with pytest 3.9.1 😕
Any idea what's happening?
#4104 only changed behavior of recwarn on python 2.x so this is probably somewhere else in the stack
No branches or pull requests
This is probably related to #1043, but that was reported before the pytest_warnings plugin was merged into pytest proper.
What I'm seeing is a warning recorded for every realization of a parameterized fixture instead of only one.
Now given this mwe.py:
I expected
pytest -s -W once::DeprecationWarning mwe.py
to print exactly one notice for the warning.I get all three, however:
Running
python -W once::DeprecationWarning mwe.py
shows what I was expecting:edit: improved formatting
The text was updated successfully, but these errors were encountered: