From: Michael Droettboom Date: Thu, 14 Jul 2022 21:46:40 +0000 (-0400) Subject: GH-94808: Cover handling non-finite numbers from round when ndigits is provided ... X-Git-Tag: v3.12.0a1~956 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=625ba9bdff51baddf9d5e156e5facf05fa1003d6;p=thirdparty%2FPython%2Fcpython.git GH-94808: Cover handling non-finite numbers from round when ndigits is provided (GH-94860) --- diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py index 672ec1411555..b5e271abc86a 100644 --- a/Lib/test/test_float.py +++ b/Lib/test/test_float.py @@ -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)