summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Bruhin <me@the-compiler.org>2023-03-14 11:57:24 +0100
committerFlorian Bruhin <me@the-compiler.org>2023-03-14 11:57:24 +0100
commit6e48c9f1a9e782f877672565aff290f8028d300d (patch)
treec789ef4a581f07b95437abeda6a9164829037608
parent9d9a7b3b841cc38c9cb4d8665a0a1d11dff24d3b (diff)
downloadqutebrowser-6e48c9f1a9e782f877672565aff290f8028d300d.tar.gz
qutebrowser-6e48c9f1a9e782f877672565aff290f8028d300d.zip
Revert "lint: add stacklevel kwarg to warnings"
This reverts commit 47be6f3aeb886cf10f85158af18b13906fc68704. This doesn't really make sense in test files, as the warning would point inside some internal pytest code, which is not helpful. Instead, let's just disable the corresponding flake8 warning in tests.
-rw-r--r--tests/end2end/fixtures/testprocess.py2
-rw-r--r--tests/test_conftest.py2
-rw-r--r--tests/unit/config/test_configtypes.py2
-rw-r--r--tests/unit/utils/test_log.py14
4 files changed, 10 insertions, 10 deletions
diff --git a/tests/end2end/fixtures/testprocess.py b/tests/end2end/fixtures/testprocess.py
index 9276a4820..96e700390 100644
--- a/tests/end2end/fixtures/testprocess.py
+++ b/tests/end2end/fixtures/testprocess.py
@@ -319,7 +319,7 @@ class Process(QObject):
if not ok:
cmdline = ' '.join([self.proc.program()] + self.proc.arguments())
warnings.warn(f"Test process {cmdline} with PID {self.proc.processId()} "
- "failed to terminate!", stacklevel=2)
+ "failed to terminate!")
self.proc.kill()
self.proc.waitForFinished()
diff --git a/tests/test_conftest.py b/tests/test_conftest.py
index 2019bfd0b..fedc6b43f 100644
--- a/tests/test_conftest.py
+++ b/tests/test_conftest.py
@@ -41,7 +41,7 @@ def test_no_qapp(request):
def test_fail_on_warnings():
with pytest.raises(PendingDeprecationWarning):
- warnings.warn('test', PendingDeprecationWarning, stacklevel=2)
+ warnings.warn('test', PendingDeprecationWarning)
@pytest.mark.xfail(reason="https://github.com/qutebrowser/qutebrowser/issues/1070",
diff --git a/tests/unit/config/test_configtypes.py b/tests/unit/config/test_configtypes.py
index 22ac3e9df..99b8a5de0 100644
--- a/tests/unit/config/test_configtypes.py
+++ b/tests/unit/config/test_configtypes.py
@@ -1521,7 +1521,7 @@ class TestRegex:
"""
regex = klass()
m = mocker.patch('qutebrowser.config.configtypes.re')
- m.compile.side_effect = lambda *args: warnings.warn(warning, stacklevel=2)
+ m.compile.side_effect = lambda *args: warnings.warn(warning)
m.error = re.error
with pytest.raises(type(warning)):
regex.to_py('foo')
diff --git a/tests/unit/utils/test_log.py b/tests/unit/utils/test_log.py
index 0a03ea7ee..bbc6b02db 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, stacklevel=2)
+ warnings.warn("test warning", PendingDeprecationWarning)
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, stacklevel=2)
+ warnings.warn("test warning", PendingDeprecationWarning)
@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, stacklevel=2)
+ warnings.warn("hidden", UserWarning)
with caplog.at_level(logging.WARNING):
- warnings.warn("not hidden", UserWarning, stacklevel=2)
+ warnings.warn("not hidden", UserWarning)
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, stacklevel=2)
+ warnings.warn("hidden", UserWarning)
with log.py_warning_filter('error'):
with pytest.raises(UserWarning):
- warnings.warn("error", UserWarning, stacklevel=2)
+ warnings.warn("error", UserWarning)
def test_warning_still_errors():
# Mainly a sanity check after the tests messing with warnings above.
with pytest.raises(UserWarning):
- warnings.warn("error", UserWarning, stacklevel=2)
+ warnings.warn("error", UserWarning)
class TestQtMessageHandler: