From 3cd7327c7b04d6f2f6de29a5084ba37c04480e4e Mon Sep 17 00:00:00 2001 From: Michael Droettboom Date: Tue, 12 Jul 2022 13:59:20 -0400 Subject: [PATCH] gh-94808: Cover handling non-finite numbers from round when ndigits is provided --- 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)