From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Fri, 15 Jul 2022 17:34:18 +0000 (-0700) Subject: [3.11] GH-94808: Cover handling non-finite numbers from round when ndigits is provide... X-Git-Tag: v3.11.0b5~73 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e55f60db8f84131bc6c3cbf453b66fd4f13c3f0f;p=thirdparty%2FPython%2Fcpython.git [3.11] GH-94808: Cover handling non-finite numbers from round when ndigits is provided (GH-94860) (GH-94882) (cherry picked from commit 625ba9bdff51baddf9d5e156e5facf05fa1003d6) Co-authored-by: Michael Droettboom Automerge-Triggered-By: GH:brandtbucher --- diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py index d8c0fe1854eb..e99250199975 100644 --- a/Lib/test/test_float.py +++ b/Lib/test/test_float.py @@ -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)