summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_codecs.py
diff options
context:
space:
mode:
authorNikita Sobolev <mail@sobolevn.me>2023-07-07 20:42:40 (GMT)
committerGitHub <noreply@github.com>2023-07-07 20:42:40 (GMT)
commit6e6a4cd52332017b10c8d88fbbbfe015948093f4 (patch)
tree94e358a6886d827fdeea2fdece4f74573f23af35 /Lib/test/test_codecs.py
parent80b9b3a51757ebb1e3547afc349a229706eadfde (diff)
downloadcpython-6e6a4cd52332017b10c8d88fbbbfe015948093f4.zip
cpython-6e6a4cd52332017b10c8d88fbbbfe015948093f4.tar.gz
cpython-6e6a4cd52332017b10c8d88fbbbfe015948093f4.tar.bz2
gh-106300: Improve `assertRaises(Exception)` usages in tests (GH-106302)
Diffstat (limited to 'Lib/test/test_codecs.py')
-rw-r--r--Lib/test/test_codecs.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/test/test_codecs.py b/Lib/test/test_codecs.py
index 376175f..91d7eaf 100644
--- a/Lib/test/test_codecs.py
+++ b/Lib/test/test_codecs.py
@@ -2822,14 +2822,15 @@ class TransformCodecTest(unittest.TestCase):
def test_custom_zlib_error_is_noted(self):
# Check zlib codec gives a good error for malformed input
msg = "decoding with 'zlib_codec' codec failed"
- with self.assertRaises(Exception) as failure:
+ with self.assertRaises(zlib.error) as failure:
codecs.decode(b"hello", "zlib_codec")
self.assertEqual(msg, failure.exception.__notes__[0])
def test_custom_hex_error_is_noted(self):
# Check hex codec gives a good error for malformed input
+ import binascii
msg = "decoding with 'hex_codec' codec failed"
- with self.assertRaises(Exception) as failure:
+ with self.assertRaises(binascii.Error) as failure:
codecs.decode(b"hello", "hex_codec")
self.assertEqual(msg, failure.exception.__notes__[0])