Esempio n. 1
0
 def test_hash_dict(self):
     obj = dict(a='hello', b='there')
     obj_rev = dict(b='there', a='hello')
     self.assertTrue(hash_object(obj))
     self.assertNotEqual(hash(convert_hashable(obj)), hash_object(obj))
     # For now I guess differently ordered dicts should be hashed the same
     self.assertEqual(hash_object(obj), hash_object(obj_rev))
Esempio n. 2
0
 def test_hash_pandas(self):
     df = pd.DataFrame(
         dict(column1=[1, 3, 5], column2=[2, 3, 5], name='hello'))
     df2 = pd.DataFrame(
         dict(column1=[1, 3, 5], column2=[2, 3, 5], name='hello2'))
     self.assertTrue(hash_object(df))
     self.assertNotEqual(hash_object(df), hash_object(df2))
     self.assertNotEqual(hash_object(df),
                         hash_object(df.rename_axis('newindex', axis=0)))
     self.assertNotEqual(hash_object(df),
                         hash_object(df.rename_axis('newcolumns', axis=1)))
Esempio n. 3
0
 def test_hash_hashable(self):
     obj = (1, 2)
     rev_tuple = (2, 1)
     self.assertTrue(hash_object(obj))
     self.assertNotEqual(hash_object(obj), hash_object(rev_tuple))
     self.assertTrue(hash_object(frozenset(obj)))
Esempio n. 4
0
 def test_hash_set(self):
     obj = {1, 2}
     self.assertTrue(hash_object(obj))
     self.assertNotEqual(hash(convert_hashable(obj)), hash_object(obj))
Esempio n. 5
0
 def test_hash_list(self):
     obj = [1, 2]
     obj_rev = list(reversed(obj))
     self.assertTrue(hash_object(obj))
     self.assertNotEqual(hash(convert_hashable(obj)), hash_object(obj))
     self.assertNotEqual(hash_object(obj), hash_object(obj_rev))