MCPcopy Index your code
hub / github.com/python/cpython / test_disallow_instantiation

Method test_disallow_instantiation

Lib/test/test_hashlib.py:1169–1182  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1167
1168 @support.cpython_only
1169 def test_disallow_instantiation(self):
1170 for algorithm, constructors in self.constructors_to_test.items():
1171 if algorithm.startswith(("sha3_", "shake", "blake")):
1172 # _sha3 and _blake types can be instantiated
1173 continue
1174 # all other types have DISALLOW_INSTANTIATION
1175 for constructor in constructors:
1176 # In FIPS mode some algorithms are not available raising ValueError
1177 try:
1178 h = constructor()
1179 except ValueError:
1180 continue
1181 with self.subTest(constructor=constructor):
1182 support.check_disallow_instantiation(self, type(h))
1183
1184 @unittest.skipUnless(HASH is not None, 'need _hashlib')
1185 def test_hash_disallow_instantiation(self):

Callers

nothing calls this directly

Calls 4

constructorFunction · 0.85
itemsMethod · 0.45
startswithMethod · 0.45
subTestMethod · 0.45

Tested by

no test coverage detected