diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2023-07-08 08:22:33 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-08 08:22:33 (GMT) |
commit | 6cd08a566f11ff6862ccf8637d01b179da46515a (patch) | |
tree | 2df3e0303226b4d6dad21a5f20217c61b08281ce /Lib/test/test_codecs.py | |
parent | 1931c2a438c50e6250725c84dff94fc760b9b951 (diff) | |
download | cpython-6cd08a566f11ff6862ccf8637d01b179da46515a.zip cpython-6cd08a566f11ff6862ccf8637d01b179da46515a.tar.gz cpython-6cd08a566f11ff6862ccf8637d01b179da46515a.tar.bz2 |
[3.11] gh-106300: Improve `assertRaises(Exception)` usages in tests (GH-106302). (GH-106545)
(cherry picked from commit 6e6a4cd52332017b10c8d88fbbbfe015948093f4)
Co-authored-by: Nikita Sobolev <mail@sobolevn.me>
Diffstat (limited to 'Lib/test/test_codecs.py')
-rw-r--r-- | Lib/test/test_codecs.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py index 934e4bb..e170a30 100644 --- a/Lib/test/test_codecs.py +++ b/Lib/test/test_codecs.py @@ -2823,15 +2823,16 @@ class TransformCodecTest(unittest.TestCase): def test_custom_zlib_error_is_wrapped(self): # Check zlib codec gives a good error for malformed input msg = "^decoding with 'zlib_codec' codec failed" - with self.assertRaisesRegex(Exception, msg) as failure: + with self.assertRaises(zlib.error) as failure: codecs.decode(b"hello", "zlib_codec") self.assertIsInstance(failure.exception.__cause__, type(failure.exception)) def test_custom_hex_error_is_wrapped(self): # Check hex codec gives a good error for malformed input + import binascii msg = "^decoding with 'hex_codec' codec failed" - with self.assertRaisesRegex(Exception, msg) as failure: + with self.assertRaises(binascii.Error) as failure: codecs.decode(b"hello", "hex_codec") self.assertIsInstance(failure.exception.__cause__, type(failure.exception)) |