diff options
author | Erlend Egeberg Aasland <erlend.aasland@innova.no> | 2021-05-27 06:43:52 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-27 06:43:52 (GMT) |
commit | fbff5387c3e1f3904420fa5a27738c6c5881305b (patch) | |
tree | a4e01083dde3afdde7306e55f70c1493fdc07b0a /Lib/test/test_hashlib.py | |
parent | 3e7ee02327db13e4337374597cdc4458ecb9e3ad (diff) | |
download | cpython-fbff5387c3e1f3904420fa5a27738c6c5881305b.zip cpython-fbff5387c3e1f3904420fa5a27738c6c5881305b.tar.gz cpython-fbff5387c3e1f3904420fa5a27738c6c5881305b.tar.bz2 |
bpo-43988: Use check disallow instantiation helper (GH-26392)
Diffstat (limited to 'Lib/test/test_hashlib.py')
-rw-r--r-- | Lib/test/test_hashlib.py | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py index ad2ed69..e419b38 100644 --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -911,20 +911,13 @@ class HashLibTestCase(unittest.TestCase): for constructor in constructors: h = constructor() with self.subTest(constructor=constructor): - hash_type = type(h) - self.assertRaises(TypeError, hash_type) + support.check_disallow_instantiation(self, type(h)) @unittest.skipUnless(HASH is not None, 'need _hashlib') - def test_hash_disallow_instanciation(self): + def test_hash_disallow_instantiation(self): # internal types like _hashlib.HASH are not constructable - with self.assertRaisesRegex( - TypeError, "cannot create '_hashlib.HASH' instance" - ): - HASH() - with self.assertRaisesRegex( - TypeError, "cannot create '_hashlib.HASHXOF' instance" - ): - HASHXOF() + support.check_disallow_instantiation(self, HASH) + support.check_disallow_instantiation(self, HASHXOF) def test_readonly_types(self): for algorithm, constructors in self.constructors_to_test.items(): |