summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMichael Droettboom <mdboom@gmail.com>2022-07-14 21:46:40 (GMT)
committerGitHub <noreply@github.com>2022-07-14 21:46:40 (GMT)
commit625ba9bdff51baddf9d5e156e5facf05fa1003d6 (patch)
tree68fbbcc60459e5db7b06478203991429cb865d10 /Lib
parent20b9d2a658059c8c1624400f60bb6ba19a31ee9b (diff)
downloadcpython-625ba9bdff51baddf9d5e156e5facf05fa1003d6.zip
cpython-625ba9bdff51baddf9d5e156e5facf05fa1003d6.tar.gz
cpython-625ba9bdff51baddf9d5e156e5facf05fa1003d6.tar.bz2
GH-94808: Cover handling non-finite numbers from round when ndigits is provided (GH-94860)
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_float.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py
index 672ec14..b5e271a 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)