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

Method test_shakes_invalid_digest_length

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

Source from the content-addressed store, hash-verified

411 self.assertEqual(h.hexdigest(0), '')
412
413 def test_shakes_invalid_digest_length(self):
414 # See https://github.com/python/cpython/issues/79103.
415 for constructor in self.shake_constructors:
416 with self.subTest(constructor=constructor):
417 h = constructor(usedforsecurity=False)
418 # Note: digest() and hexdigest() take a signed input and
419 # raise if it is negative; the rationale is that we use
420 # internally PyBytes_FromStringAndSize() and _Py_strhex()
421 # which both take a Py_ssize_t.
422 for negative_size in (-1, -10, -(1 << 31), -sys.maxsize):
423 self.assertRaises(ValueError, h.digest, negative_size)
424 self.assertRaises(ValueError, h.hexdigest, negative_size)
425
426 def test_shakes_overflow_digest_length(self):
427 # See https://github.com/python/cpython/issues/135759.

Callers

nothing calls this directly

Calls 3

constructorFunction · 0.85
subTestMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected