-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
psf/requests
#4056Labels
plugin: warningsrelated to the warnings builtin pluginrelated to the warnings builtin plugintype: bugproblem that needs to be addressedproblem that needs to be addressedtype: regressionindicates a problem that was introduced in a release which was working previouslyindicates a problem that was introduced in a release which was working previously
Description
SQLAlchemy CI is now broken due to the unconditional inclusion of pytest-warnings in py.test 3.1.0. I need at least to know how to disable this plugin entirely.
In our test suite we make use of the warnings filter internally in order to propagate our own warnings to errors. It seems like warnings.filter() is now non-functional when this plugin is installed.
Demo test case:
import warnings
class MyWarning(Warning):
pass
warnings.filterwarnings("error", category=MyWarning)
class TestWarnings(object):
def test_my_warning(self):
try:
warnings.warn(MyWarning("warn!"))
assert False
except MyWarning:
assert True
with py.test 3.0.7:
$ py.test test_warning.py
======================================================== test session starts ========================================================
platform linux2 -- Python 2.7.13, pytest-3.0.7, py-1.4.33, pluggy-0.4.0
rootdir: /home/classic/Desktop/tmp, inifile:
plugins: xdist-1.15.0, cov-2.4.0
collected 1 items
test_warning.py .
===================================================== 1 passed in 0.01 seconds ======================================================
with py.test 3.1.0:
$ py.test test_warning.py
======================================================== test session starts ========================================================
platform linux2 -- Python 2.7.13, pytest-3.1.0, py-1.4.33, pluggy-0.4.0
rootdir: /home/classic/Desktop/tmp, inifile:
plugins: xdist-1.15.0, cov-2.4.0
collected 1 items
test_warning.py F
============================================================= FAILURES ==============================================================
___________________________________________________ TestWarnings.test_my_warning ____________________________________________________
self = <test_warning.TestWarnings object at 0x7fecb08a5290>
def test_my_warning(self):
try:
warnings.warn(MyWarning("warn!"))
> assert False
E assert False
test_warning.py:12: AssertionError
========================================================= warnings summary ==========================================================
test_warning.py::TestWarnings::()::test_my_warning
/home/classic/Desktop/tmp/test_warning.py:11: MyWarning: warn!
warnings.warn(MyWarning("warn!"))
-- Docs: http://doc.pytest.org/en/latest/warnings.html
=============================================== 1 failed, 1 warnings in 0.03 seconds ================================================
I have tried everything I can think of with the new -W flag, disable-warnings, no luck.
Please advise on the correct options to allow Python stdlib warnings.filter() to work again, thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
plugin: warningsrelated to the warnings builtin pluginrelated to the warnings builtin plugintype: bugproblem that needs to be addressedproblem that needs to be addressedtype: regressionindicates a problem that was introduced in a release which was working previouslyindicates a problem that was introduced in a release which was working previously