def testDirAndFile(self):
"""Test hashing a directory with one file.
The hash sum should stay stable in the long run as this might be used
for binary artifact matching in the future.
"""
with TemporaryDirectory() as tmp:
os.mkdir(os.path.join(tmp, "dir"))
with open(os.path.join(tmp, "dir", "file"), 'wb') as f:
f.write(b'abc')
sum1 = hashDirectory(tmp)
assert len(sum1) == 20
assert sum1 == binascii.unhexlify(
"640f516de78fba0b6d2ddde4451000f142d06b0d")
sum2 = hashDirectory(tmp)
assert sum1 == sum2
评论列表
文章目录