From 625ba9bdff51baddf9d5e156e5facf05fa1003d6 Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Thu, 14 Jul 2022 17:46:40 -0400 Subject: [PATCH] GH-94808: Cover handling non-finite numbers from round when ndigits is provided (GH-94860) --- Lib/test/test_float.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py index 672ec141155530..b5e271abc86a5e 100644 --- a/Lib/test/test_float.py +++ b/Lib/test/test_float.py @@ -831,6 +831,11 @@ def test_inf_nan(self): 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)