]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-94808: Cover handling non-finite numbers from round when ndigits is provided ...
authorMichael Droettboom <mdboom@gmail.com>
Thu, 14 Jul 2022 21:46:40 +0000 (17:46 -0400)
committerGitHub <noreply@github.com>
Thu, 14 Jul 2022 21:46:40 +0000 (14:46 -0700)
Lib/test/test_float.py

index 672ec141155530b3279d6d8e671565ced9786747..b5e271abc86a5ec5b1a0a2741ec39db3cd43182c 100644 (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)