def test_hash_distance(self): _, name = tempfile.mkstemp(suffix=".png") self._get_test_image().save(name, "PNG") hash, _ = pdq.get_hash(name) dist_to_zero = pdq.distance(hash, [0] * len(hash)) self.assertEqual(pdq.distance(hash, hash), 0) self.assertNotEqual(dist_to_zero, 0) self.assertEqual(dist_to_zero, pdq.norm(hash))
def test_file_not_found(self): with self.assertRaises(FileNotFoundError): pdq.get_hash("not_a_file.png")
def test_bad_args(self): with self.assertRaises(ValueError): pdq.get_hash(1, 2, 3)
def test_png_image(self): _, name = tempfile.mkstemp(suffix=".png") self._get_test_image().save(name, "PNG") hash, quality = pdq.get_hash(name) self.assertEqual(len(hash), 16) self.assertGreaterEqual(quality, 0)