diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2017-05-01 18:18:56 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-01 18:18:56 +0200 |
commit | 5d7a8d0c13737fd531b722ad76c505ef47aac96a (patch) | |
tree | 2ad8be6cb6bc56b9e8847468aad7edb1416472b5 /Lib/unittest/test/test_assertions.py | |
parent | 1374dbb6940f29c49c2966551a06015857c942cc (diff) | |
download | cpython-5d7a8d0c13737fd531b722ad76c505ef47aac96a.tar.gz cpython-5d7a8d0c13737fd531b722ad76c505ef47aac96a.zip |
bpo-30190: improved error msg for assertAlmostEqual(delta=...) (#1331)
* #30190 / unittest / assertAlmostEqual(delta=...) / error msg: show the difference between the 2 numbers in case of failure
* safe_repr() diff
* also show difference when passing 'places' argument
* refactoring
* update Misc/NEWS
Diffstat (limited to 'Lib/unittest/test/test_assertions.py')
-rw-r--r-- | Lib/unittest/test/test_assertions.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/unittest/test/test_assertions.py b/Lib/unittest/test/test_assertions.py index 31565da9849..b046669e19d 100644 --- a/Lib/unittest/test/test_assertions.py +++ b/Lib/unittest/test/test_assertions.py @@ -223,9 +223,11 @@ class TestLongMessage(unittest.TestCase): "^1 == 1 : oops$"]) def testAlmostEqual(self): - self.assertMessages('assertAlmostEqual', (1, 2), - ["^1 != 2 within 7 places$", "^oops$", - "^1 != 2 within 7 places$", "^1 != 2 within 7 places : oops$"]) + self.assertMessages( + 'assertAlmostEqual', (1, 2), + ["^1 != 2 within 7 places \(1 difference\)$", "^oops$", + "^1 != 2 within 7 places \(1 difference\)$", + "^1 != 2 within 7 places \(1 difference\) : oops$"]) def testNotAlmostEqual(self): self.assertMessages('assertNotAlmostEqual', (1, 1), |