[Python-checkins] [3.11] GH-94808: Cover handling non-finite numbers from round when ndigits is provided (GH-94860) (GH-94882)
miss-islington
webhook-mailer at python.org
Fri Jul 15 13:34:23 EDT 2022
https://github.com/python/cpython/commit/e55f60db8f84131bc6c3cbf453b66fd4f13c3f0f
commit: e55f60db8f84131bc6c3cbf453b66fd4f13c3f0f
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-07-15T10:34:18-07:00
summary:
[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 <mdboom at gmail.com>
Automerge-Triggered-By: GH:brandtbucher
files:
M Lib/test/test_float.py
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py
index d8c0fe1854eba..e99250199975b 100644
--- a/Lib/test/test_float.py
+++ b/Lib/test/test_float.py
@@ -832,6 +832,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)
More information about the Python-checkins
mailing list