Newer
Older
import tempfile
from pathlib import Path
from bitia.common import sha256sum
def test_filehash():
tempdir = tempfile.gettempdir()
t1 = "ls -ltrh /"
t2 = "ls -ltrh"
f1 = Path(tempdir) / "a.txt"
f2 = Path(tempdir) / "b.txt"
f1.write_text(t1)
f2.write_text(t1)
assert sha256sum(f1) == sha256sum(f2)
f2.write_text(t2)
assert sha256sum(f1) != sha256sum(f2)
f1.write_text(t2)
assert sha256sum(f1) == sha256sum(f2)