mirror of
https://github.com/python/cpython.git
synced 2025-11-11 14:44:57 +00:00
#18663: document that assertAlmostEqual also works when the values are equal and add tests.
This commit is contained in:
parent
7608b607b1
commit
d51914c6c1
2 changed files with 5 additions and 1 deletions
|
|
@ -1000,7 +1000,7 @@ Test cases
|
||||||
like the :func:`round` function) and not *significant digits*.
|
like the :func:`round` function) and not *significant digits*.
|
||||||
|
|
||||||
If *delta* is supplied instead of *places* then the difference
|
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``.
|
Supplying both *delta* and *places* raises a ``TypeError``.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,10 @@ class Test_Assertions(unittest.TestCase):
|
||||||
self.assertNotAlmostEqual(1.1, 1.0, delta=0.05)
|
self.assertNotAlmostEqual(1.1, 1.0, delta=0.05)
|
||||||
self.assertNotAlmostEqual(1.0, 1.1, 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,
|
self.assertRaises(self.failureException, self.assertAlmostEqual,
|
||||||
1.1, 1.0, delta=0.05)
|
1.1, 1.0, delta=0.05)
|
||||||
self.assertRaises(self.failureException, self.assertNotAlmostEqual,
|
self.assertRaises(self.failureException, self.assertNotAlmostEqual,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue