From 300b986782c754be462788a30e0355301683c0ed Mon Sep 17 00:00:00 2001 From: SomberNight Date: Mon, 10 Jun 2024 20:22:20 +0000 Subject: [PATCH] soothe flake8 ``` ./tests/test_mnemonic.py:249:9: B017 `assertRaises(Exception)` and `pytest.raises(Exception)` should be considered evil. They can lead to your test passing even if the code being tested is never executed due to a typo. Assert for a more specific exception (builtin or custom), or use `assertRaisesRegex` (if using `assertRaises`), or add the `match` keyword argument (if using `pytest.raises`), or use the context manager form with a target. with self.assertRaises(Exception): ^ 1 B017 `assertRaises(Exception)` and `pytest.raises(Exception)` should be considered evil. They can lead to your test passing even if the code being tested is never executed due to a typo. Assert for a more specific exception (builtin or custom), or use `assertRaisesRegex` (if using `assertRaises`), or add the `match` keyword argument (if using `pytest.raises`), or use the context manager form with a target. ``` --- tests/test_mnemonic.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tests/test_mnemonic.py b/tests/test_mnemonic.py index 77e1fb4bc..523453d81 100644 --- a/tests/test_mnemonic.py +++ b/tests/test_mnemonic.py @@ -246,8 +246,9 @@ class Test_seeds(ElectrumTestCase): def test_can_seed_have_passphrase(self): seed_invalid = 'xxx' - with self.assertRaises(Exception): + with self.assertRaises(Exception) as ctx: self.assertFalse(can_seed_have_passphrase(seed_invalid)) + self.assertTrue("unexpected seed type" in ctx.exception.args[0]) seed_old = 'cell dumb heartbeat north boom tease ship baby bright kingdom rare squeeze' self.assertFalse(can_seed_have_passphrase(seed_old)) seed_standard = 'cram swing cover prefer miss modify ritual silly deliver chunk behind inform able'