MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_digest_length_overflow

Method test_digest_length_overflow

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

Source from the content-addressed store, hash-verified

365 self.assertEqual(hexstr(h.digest()), h.hexdigest())
366
367 def test_digest_length_overflow(self):
368 # See issue #34922
369 large_sizes = (2**29, 2**32-10, 2**32+10, 2**61, 2**64-10, 2**64+10)
370 for cons in self.hash_constructors:
371 h = cons(usedforsecurity=False)
372 if h.name not in self.shakes:
373 continue
374 if HASH is not None and isinstance(h, HASH):
375 # _hashopenssl's take a size_t
376 continue
377 for digest in h.digest, h.hexdigest:
378 self.assertRaises(ValueError, digest, -10)
379 for length in large_sizes:
380 with self.assertRaises((ValueError, OverflowError)):
381 digest(length)
382
383 def test_name_attribute(self):
384 for cons in self.hash_constructors:

Callers

nothing calls this directly

Calls 3

isinstanceFunction · 0.85
digestFunction · 0.85
assertRaisesMethod · 0.45

Tested by

no test coverage detected