diff options
author | Hubert Kario <hubert@kario.pl> | 2023-02-23 23:03:24 +0100 |
---|---|---|
committer | Hubert Kario <hubert@kario.pl> | 2023-02-24 15:41:56 +0100 |
commit | 50c1fa44f35b9d383ffbc3e045a94419f6c347d1 (patch) | |
tree | afc1d3f9c070b73763e3866d28b873f19e8cd0f3 | |
parent | f10e6d9be1251f9a109c0c2002ed12fee818b883 (diff) | |
download | ecdsa-50c1fa44f35b9d383ffbc3e045a94419f6c347d1.tar.gz |
use recommended convention for testing that no warnings were raised
-rw-r--r-- | src/ecdsa/test_der.py | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/src/ecdsa/test_der.py b/src/ecdsa/test_der.py index 0ca5bd7..833d12d 100644 --- a/src/ecdsa/test_der.py +++ b/src/ecdsa/test_der.py @@ -144,26 +144,22 @@ class TestEncodeBitstring(unittest.TestCase): def test_new_call_convention(self): """This is how it should be called now.""" - warnings.simplefilter("always") - with pytest.warns(None) as warns: + # make sure no warnings are raised + with warnings.catch_warnings(): + warnings.simplefilter("error") der = encode_bitstring(b"\xff", 0) - # verify that new call convention doesn't raise Warnings - self.assertEqual(len(warns), 0) - self.assertEqual(der, b"\x03\x02\x00\xff") def test_implicit_unused_bits(self): """ Writing bit string with already included the number of unused bits. """ - warnings.simplefilter("always") - with pytest.warns(None) as warns: + # make sure no warnings are raised + with warnings.catch_warnings(): + warnings.simplefilter("error") der = encode_bitstring(b"\x00\xff", None) - # verify that new call convention doesn't raise Warnings - self.assertEqual(len(warns), 0) - self.assertEqual(der, b"\x03\x02\x00\xff") def test_explicit_unused_bits(self): @@ -203,22 +199,20 @@ class TestRemoveBitstring(unittest.TestCase): self.assertEqual(rest, b"") def test_new_call_convention(self): - warnings.simplefilter("always") - with pytest.warns(None) as warns: + # make sure no warnings are raised + with warnings.catch_warnings(): + warnings.simplefilter("error") bits, rest = remove_bitstring(b"\x03\x02\x00\xff", 0) - self.assertEqual(len(warns), 0) - self.assertEqual(bits, b"\xff") self.assertEqual(rest, b"") def test_implicit_unexpected_unused(self): - warnings.simplefilter("always") - with pytest.warns(None) as warns: + # make sure no warnings are raised + with warnings.catch_warnings(): + warnings.simplefilter("error") bits, rest = remove_bitstring(b"\x03\x02\x00\xff", None) - self.assertEqual(len(warns), 0) - self.assertEqual(bits, (b"\xff", 0)) self.assertEqual(rest, b"") |