def test__eq__(self): # two genome are called equal if they are both os same class and their hash values are equal g1 = BGGenome("name1") g2 = BGGenome("name2") self.assertNotEqual(g1, g2) g2.name = "name1" self.assertEqual(g1, g2) self.assertNotEqual(g1, 5) self.assertNotEqual(g1, "name1") self.assertNotEqual(g1, [g1])
def test_json_id(self): # json id for genome is utilized when genome is serialized to json format and equals to hash value of genome instance g = BGGenome("name") json_id = g.json_id self.assertEqual(json_id, hash(g.name)) self.assertTrue(isinstance(json_id, int)) g.name = "name1" new_json_id = g.json_id self.assertEqual(new_json_id, hash(g.name)) self.assertTrue(isinstance(json_id, int)) self.assertNotEqual(json_id, new_json_id)