Skip to content

Commit 4d0c077

Browse files
mdboommiss-islington
authored andcommitted
pythonGH-94808: Cover handling non-finite numbers from round when ndigits is provided (pythonGH-94860)
(cherry picked from commit 625ba9b) Co-authored-by: Michael Droettboom <mdboom@gmail.com>
1 parent d9107aa commit 4d0c077

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

Lib/test/test_float.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,11 @@ def test_inf_nan(self):
832832
self.assertRaises(TypeError, round, NAN, "ceci n'est pas un integer")
833833
self.assertRaises(TypeError, round, -0.0, 1j)
834834

835+
def test_inf_nan_ndigits(self):
836+
self.assertEqual(round(INF, 0), INF)
837+
self.assertEqual(round(-INF, 0), -INF)
838+
self.assertTrue(math.isnan(round(NAN, 0)))
839+
835840
def test_large_n(self):
836841
for n in [324, 325, 400, 2**31-1, 2**31, 2**32, 2**100]:
837842
self.assertEqual(round(123.456, n), 123.456)

0 commit comments

Comments
 (0)