]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] GH-94808: Cover handling non-finite numbers from round when ndigits is provide...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 15 Jul 2022 17:34:18 +0000 (10:34 -0700)
committerGitHub <noreply@github.com>
Fri, 15 Jul 2022 17:34:18 +0000 (10:34 -0700)
(cherry picked from commit 625ba9bdff51baddf9d5e156e5facf05fa1003d6)

Co-authored-by: Michael Droettboom <mdboom@gmail.com>
Automerge-Triggered-By: GH:brandtbucher
Lib/test/test_float.py

index d8c0fe1854eba5a2cc22a77532a6b7ae31887bc9..e99250199975b36e2c3d3c6adc22d4c9240eee48 100644 (file)
@@ -832,6 +832,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)