MCPcopy
hub / github.com/pex-tool/pex / test_hash

Function test_hash

tests/test_util.py:44–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

42
43
44def test_hash():
45 # type: () -> None
46 empty_hash_digest = sha1().hexdigest()
47
48 with named_temporary_file() as fp:
49 fp.flush()
50 assert empty_hash_digest == CacheHelper.hash(fp.name)
51
52 with named_temporary_file() as fp:
53 string = b"asdf" * 1024 * sha1().block_size + b"extra padding"
54 fp.write(string)
55 fp.flush()
56 assert sha1(string).hexdigest() == CacheHelper.hash(fp.name)
57
58 with named_temporary_file() as fp:
59 empty_hash = sha1()
60 fp.write(b"asdf")
61 fp.flush()
62 hash_output = CacheHelper.hash(fp.name, digest=empty_hash)
63 assert hash_output == empty_hash.hexdigest()
64
65
66@pytest.mark.parametrize(

Callers

nothing calls this directly

Calls 4

named_temporary_fileFunction · 0.90
hashMethod · 0.80
hexdigestMethod · 0.45
writeMethod · 0.45

Tested by

no test coverage detected