Example #1
0
 def test_autoselection(self):
     x = self.create_filestorage_hash("hash")
     x.fs.store([Record(["", ""])])
     with open(x.tempfile + ".checksum", "r") as fp:
         data = fp.read()
     bitness = HashHook._bitness()
     self.assertIn(bitness, [32, 64])
     self.assertTrue(data.startswith("sha512" if bitness == 64 else "sha256"))
     x.tempdir.cleanup()
Example #2
0
 def test_hashing(self):
     tempdir = tempfile.TemporaryDirectory()
     temp = tempdir.name + "/test"
     for k in self.testcases:
         v = self.generate_len_and_hash(hashlib.sha256, k)
         with open(temp, "w") as wfp:
             wfp.write(k)
         self.assertEqual(HashHook._hash_file("sha256", temp), "sha256:" + v)
     tempdir.cleanup()