diff options
author | Christian Heimes <christian@python.org> | 2021-05-02 07:47:45 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-02 07:47:45 (GMT) |
commit | 91554e4c5ca3c762998296522f854a7166ba84f0 (patch) | |
tree | aa6e08eedef59c4a4d5c750ed60e5d463f05a4ad /Lib/test/test_hashlib.py | |
parent | fd0bc7e7f4f2c7de98a1ebc7ad1ef65b8f8f7ad6 (diff) | |
download | cpython-91554e4c5ca3c762998296522f854a7166ba84f0.zip cpython-91554e4c5ca3c762998296522f854a7166ba84f0.tar.gz cpython-91554e4c5ca3c762998296522f854a7166ba84f0.tar.bz2 |
bpo-43908: Mark ssl, hash, and hmac types as immutable (GH-25792)
Signed-off-by: Christian Heimes <christian@python.org>
Diffstat (limited to 'Lib/test/test_hashlib.py')
-rw-r--r-- | Lib/test/test_hashlib.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Lib/test/test_hashlib.py b/Lib/test/test_hashlib.py index a515d3a..ad2ed69 100644 --- a/Lib/test/test_hashlib.py +++ b/Lib/test/test_hashlib.py @@ -926,6 +926,15 @@ class HashLibTestCase(unittest.TestCase): ): HASHXOF() + def test_readonly_types(self): + for algorithm, constructors in self.constructors_to_test.items(): + # all other types have DISALLOW_INSTANTIATION + for constructor in constructors: + hash_type = type(constructor()) + with self.subTest(hash_type=hash_type): + with self.assertRaisesRegex(TypeError, "immutable type"): + hash_type.value = False + class KDFTests(unittest.TestCase): |