GH-94808: Cover handling non-finite numbers from round when ndigits is provided (GH-94860)

This commit is contained in:
Michael Droettboom 2022-07-14 17:46:40 -04:00 committed by GitHub
parent 20b9d2a658
commit 625ba9bdff
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -831,6 +831,11 @@ class RoundTestCase(unittest.TestCase):
self.assertRaises(TypeError, round, NAN, "ceci n'est pas un integer")
self.assertRaises(TypeError, round, -0.0, 1j)
def test_inf_nan_ndigits(self):
self.assertEqual(round(INF, 0), INF)
self.assertEqual(round(-INF, 0), -INF)
self.assertTrue(math.isnan(round(NAN, 0)))
def test_large_n(self):
for n in [324, 325, 400, 2**31-1, 2**31, 2**32, 2**100]:
self.assertEqual(round(123.456, n), 123.456)