diff options
Diffstat (limited to 'tests/unit/utils/test_log.py')
-rw-r--r-- | tests/unit/utils/test_log.py | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/unit/utils/test_log.py b/tests/unit/utils/test_log.py index bbc6b02db..0a03ea7ee 100644 --- a/tests/unit/utils/test_log.py +++ b/tests/unit/utils/test_log.py @@ -275,7 +275,7 @@ class TestInitLog: log.init_log(args) with caplog.at_level(logging.WARNING): - warnings.warn("test warning", PendingDeprecationWarning) + warnings.warn("test warning", PendingDeprecationWarning, stacklevel=2) expected = "PendingDeprecationWarning: test warning" assert expected in caplog.records[0].message @@ -285,7 +285,7 @@ class TestInitLog: log.init_log(args) with pytest.raises(PendingDeprecationWarning): - warnings.warn("test warning", PendingDeprecationWarning) + warnings.warn("test warning", PendingDeprecationWarning, stacklevel=2) @pytest.mark.parametrize('cli, conf, expected', [ (None, 'info', logging.INFO), @@ -386,9 +386,9 @@ def test_stub(caplog, suffix, expected): def test_py_warning_filter(caplog): logging.captureWarnings(True) with log.py_warning_filter(category=UserWarning): - warnings.warn("hidden", UserWarning) + warnings.warn("hidden", UserWarning, stacklevel=2) with caplog.at_level(logging.WARNING): - warnings.warn("not hidden", UserWarning) + warnings.warn("not hidden", UserWarning, stacklevel=2) assert len(caplog.records) == 1 msg = caplog.messages[0].splitlines()[0] assert msg.endswith("UserWarning: not hidden") @@ -396,17 +396,17 @@ def test_py_warning_filter(caplog): def test_py_warning_filter_error(caplog): warnings.simplefilter('ignore') - warnings.warn("hidden", UserWarning) + warnings.warn("hidden", UserWarning, stacklevel=2) with log.py_warning_filter('error'): with pytest.raises(UserWarning): - warnings.warn("error", UserWarning) + warnings.warn("error", UserWarning, stacklevel=2) def test_warning_still_errors(): # Mainly a sanity check after the tests messing with warnings above. with pytest.raises(UserWarning): - warnings.warn("error", UserWarning) + warnings.warn("error", UserWarning, stacklevel=2) class TestQtMessageHandler: |