From: Ezio Melotti Date: Sun, 11 Aug 2013 10:04:50 +0000 (+0300) Subject: #18663: document that assertAlmostEqual also works when the values are equal and... X-Git-Tag: v2.7.6rc1~249 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d59914219796042b87d9ddcb232757dd5edcc459;p=thirdparty%2FPython%2Fcpython.git #18663: document that assertAlmostEqual also works when the values are equal and add tests. --- diff --git a/Doc/library/unittest.rst b/Doc/library/unittest.rst index 1bd3819bc2d7..f36a44deccfc 100644 --- a/Doc/library/unittest.rst +++ b/Doc/library/unittest.rst @@ -1017,7 +1017,7 @@ Test cases like the :func:`round` function) and not *significant digits*. If *delta* is supplied instead of *places* then the difference - between *first* and *second* must be less (or more) than *delta*. + between *first* and *second* must be less or equal to (or greater than) *delta*. Supplying both *delta* and *places* raises a ``TypeError``. diff --git a/Lib/unittest/test/test_assertions.py b/Lib/unittest/test/test_assertions.py index e1ba61470664..e8f0f64b4cf9 100644 --- a/Lib/unittest/test/test_assertions.py +++ b/Lib/unittest/test/test_assertions.py @@ -33,6 +33,10 @@ class Test_Assertions(unittest.TestCase): self.assertNotAlmostEqual(1.1, 1.0, delta=0.05) self.assertNotAlmostEqual(1.0, 1.1, delta=0.05) + self.assertAlmostEqual(1.0, 1.0, delta=0.5) + self.assertRaises(self.failureException, self.assertNotAlmostEqual, + 1.0, 1.0, delta=0.5) + self.assertRaises(self.failureException, self.assertAlmostEqual, 1.1, 1.0, delta=0.05) self.assertRaises(self.failureException, self.assertNotAlmostEqual,