mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
[3.10] bpo-43988: Add test.support.check_disallow_instantiation() (GH-25757) (GH-26885)
(cherry picked from commit4f725261c6
,fbff5387c3
, and8cec740820
) Co-authored-by: Erlend Egeberg Aasland <erlend.aasland@innova.no> Automerge-Triggered-By: GH:vstinner
This commit is contained in:
parent
ece3841d3d
commit
0a3452e7cf
16 changed files with 58 additions and 53 deletions
|
@ -6,7 +6,7 @@ import unittest
|
|||
import unittest.mock
|
||||
import warnings
|
||||
|
||||
from test.support import hashlib_helper
|
||||
from test.support import hashlib_helper, check_disallow_instantiation
|
||||
|
||||
from _operator import _compare_digest as operator_compare_digest
|
||||
|
||||
|
@ -439,11 +439,7 @@ class ConstructorTestCase(unittest.TestCase):
|
|||
@unittest.skipUnless(C_HMAC is not None, 'need _hashlib')
|
||||
def test_internal_types(self):
|
||||
# internal types like _hashlib.C_HMAC are not constructable
|
||||
with self.assertRaisesRegex(
|
||||
TypeError, "cannot create '_hashlib.HMAC' instance"
|
||||
):
|
||||
C_HMAC()
|
||||
|
||||
check_disallow_instantiation(self, C_HMAC)
|
||||
with self.assertRaisesRegex(TypeError, "immutable type"):
|
||||
C_HMAC.value = None
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue