import unittest from tudelft.utilities.tools.safehash import safehash class A: def __hash__(self): return 1 class B(A): def __hash__(self): return safehash(super())+1 class SafeHashTest(unittest.TestCase): def tests(self): lst=[1,2,3] safehash(lst) safehash({'a':1}) safehash( set(lst)) safehash({'a':set(lst)}) h1= safehash({'a':1}) h2= safehash({'a':2}) self.assertNotEqual(h1,h2) h1= safehash({'a':1,'b':2}) h2= safehash({'b':2,'a':1}) self.assertEqual(h1,h2) self.assertEqual(2, safehash(B())) # you can a set in a set... #safehash(set([set(lst)]))