diff options
author | toofar <toofar@spalge.com> | 2023-02-06 18:53:56 +1300 |
---|---|---|
committer | toofar <toofar@spalge.com> | 2023-02-06 18:53:56 +1300 |
commit | ff8dbc45805013b5a119a0d6b2c943308faeca8e (patch) | |
tree | c3c3d2337d797267b2c248dbbfae85c24adfbb1c /tests/unit/utils/test_utils.py | |
parent | 7dacc89d2ad4cf31010f69e2a40847d7a2b34fc4 (diff) | |
download | qutebrowser-ff8dbc45805013b5a119a0d6b2c943308faeca8e.tar.gz qutebrowser-ff8dbc45805013b5a119a0d6b2c943308faeca8e.zip |
lint: broad-exception-raised
Mostly pretty lazy fixes. Most of the places in the tests we were
already matching on error message, a couple of places we weren't. The
tick-tock one was the only one that wasn't being used right where it was
raised.
Some of them I just changed to RuntimeError because it was shorter than
adding the pylint directive.
Diffstat (limited to 'tests/unit/utils/test_utils.py')
-rw-r--r-- | tests/unit/utils/test_utils.py | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/tests/unit/utils/test_utils.py b/tests/unit/utils/test_utils.py index aa063b7c6..4f81783c2 100644 --- a/tests/unit/utils/test_utils.py +++ b/tests/unit/utils/test_utils.py @@ -425,7 +425,7 @@ class TestPreventExceptions: @utils.prevent_exceptions(42) def func_raising(self): - raise Exception + raise RuntimeError("something went wrong") def test_raising(self, caplog): """Test with a raising function.""" @@ -434,6 +434,7 @@ class TestPreventExceptions: assert ret == 42 expected = 'Error in test_utils.TestPreventExceptions.func_raising' assert caplog.messages == [expected] + assert caplog.records[0].exc_info[1].args[0] == "something went wrong" @utils.prevent_exceptions(42) def func_not_raising(self): @@ -448,7 +449,7 @@ class TestPreventExceptions: @utils.prevent_exceptions(42, True) def func_predicate_true(self): - raise Exception("its-true") + raise RuntimeError("its-true") def test_predicate_true(self, caplog): """Test with a True predicate.""" @@ -456,15 +457,16 @@ class TestPreventExceptions: ret = self.func_predicate_true() assert ret == 42 assert len(caplog.records) == 1 + assert caplog.records[0].exc_info[1].args[0] == "its-true" @utils.prevent_exceptions(42, False) def func_predicate_false(self): - raise Exception("its-false") + raise RuntimeError("its-false") def test_predicate_false(self, caplog): """Test with a False predicate.""" with caplog.at_level(logging.ERROR, 'misc'): - with pytest.raises(Exception, match="its-false"): + with pytest.raises(RuntimeError, match="its-false"): self.func_predicate_false() assert not caplog.records |