def test_distance(self): """distance should know the distance between the average_hash of two test images""" for i in range(len(self.photos)): for j in range(i, len(self.photos)): hamming_distance = hash_distance( self.photos[i]['average_hash'], self.photos[j]['average_hash'] ) self.assertEqual( hamming_distance, distance(self.photos[i]['path'], self.photos[j]['path']) )
def test_hash_distance(self): """hash_distance should know the hamming distance between two strings""" self.assertEqual(hash_distance('roses', 'toned'), 3) self.assertEqual(hash_distance('are', 'are'), 0) self.assertEqual(hash_distance('read', 'daer'), 4)