diff options
Diffstat (limited to 'Lib/unittest/case.py')
-rw-r--r-- | Lib/unittest/case.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Lib/unittest/case.py b/Lib/unittest/case.py index 48f3ef1..77ca278 100644 --- a/Lib/unittest/case.py +++ b/Lib/unittest/case.py @@ -468,7 +468,13 @@ class TestCase(object): Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit). + + If the two objects compare equal then they will automatically + compare almost equal. """ + if first == second: + # shortcut for ite + return if round(abs(second-first), places) != 0: standardMsg = '%r != %r within %r places' % (first, second, places) msg = self._formatMessage(msg, standardMsg) @@ -481,8 +487,10 @@ class TestCase(object): Note that decimal places (from zero) are usually not the same as significant digits (measured from the most signficant digit). + + Objects that are equal automatically fail. """ - if round(abs(second-first), places) == 0: + if (first == second) or round(abs(second-first), places) == 0: standardMsg = '%r == %r within %r places' % (first, second, places) msg = self._formatMessage(msg, standardMsg) raise self.failureException(msg) |