def test_equals(self): random_z = random.randint(1, 92) fixed_el = Element.from_Z(random_z) other_z = random.randint(1, 92) while other_z == random_z: other_z = random.randint(1, 92) comp1 = Ion(Composition({fixed_el: 1, Element.from_Z(other_z): 0}), 1) other_z = random.randint(1, 92) while other_z == random_z: other_z = random.randint(1, 92) comp2 = Ion(Composition({fixed_el: 1, Element.from_Z(other_z): 0}), 1) self.assertEqual( comp1, comp2, "Composition equality test failed. " + "%s should be equal to %s" % (comp1.formula, comp2.formula)) self.assertEqual(comp1.__hash__(), comp2.__hash__(), "Hashcode equality test failed!")
def test_equals(self): random_z = random.randint(1, 92) fixed_el = Element.from_Z(random_z) other_z = random.randint(1, 92) while other_z == random_z: other_z = random.randint(1, 92) comp1 = Ion(Composition({fixed_el: 1, Element.from_Z(other_z): 0}), 1) other_z = random.randint(1, 92) while other_z == random_z: other_z = random.randint(1, 92) comp2 = Ion(Composition({fixed_el: 1, Element.from_Z(other_z): 0}), 1) self.assertEqual(comp1, comp2, "Composition equality test failed. " + "%s should be equal to %s" % (comp1.formula, comp2.formula)) self.assertEqual(comp1.__hash__(), comp2.__hash__(), "Hashcode equality test failed!")