diff --git a/tests/conftest.py b/tests/conftest.py index 43d5e0e25..e53998406 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -27,6 +27,7 @@ import collections import itertools import logging import textwrap +import warnings import pytest @@ -309,3 +310,10 @@ def py_proc(): def func(code): return (sys.executable, ['-c', textwrap.dedent(code.strip('\n'))]) return func + + +@pytest.yield_fixture(autouse=True) +def fail_tests_on_warnings(): + warnings.simplefilter('error') + yield + warnings.resetwarnings() diff --git a/tests/test_conftest.py b/tests/test_conftest.py index ffb45986d..0af725f30 100644 --- a/tests/test_conftest.py +++ b/tests/test_conftest.py @@ -20,6 +20,11 @@ """Various meta-tests for conftest.py.""" +import warnings + +import pytest + + def test_qapp_name(qapp): """Make sure the QApplication name is changed when we use qapp.""" assert qapp.applicationName() == 'qute_test' @@ -28,3 +33,8 @@ def test_qapp_name(qapp): def test_no_qapp(request): """Make sure a test without qapp doesn't use qapp (via autouse).""" assert 'qapp' not in request.fixturenames + + +def test_fail_on_warnings(): + with pytest.raises(PendingDeprecationWarning): + warnings.warn('test', PendingDeprecationWarning)