Skip to content

Commit

Permalink
Add test_numbers_equal() to explicitly verify numeric comparison.
Browse files Browse the repository at this point in the history
If __eq__() mis-handles NaN values, it's possible for differences
containing unequal numbers to wrongly test as equal.
  • Loading branch information
shawnbrown committed Jul 15, 2019
1 parent bee6aa8 commit 32d3bb9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tests/test_difference.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,15 @@ class MyClass(object):
diff = MinimalDifference('A', MyClass)
self.assertEqual(repr(diff), "MinimalDifference('A', MyClass)")

def test_numbers_equal(self):
first = MinimalDifference(1)
second = MinimalDifference(1.0)
self.assertEqual(first, second)

first = MinimalDifference(1)
second = MinimalDifference(2)
self.assertNotEqual(first, second)

def test_string_equal(self):
first = MinimalDifference('A')
second = MinimalDifference('A')
Expand Down

0 comments on commit 32d3bb9

Please sign in to comment.