[3.11] GH-94808: Cover handling non-finite numbers from round when nd… · python/cpython@e55f60d

GitHub

GitHub CopilotWrite better code with AI | MCP RegistryIntegrate external tools | ActionsAutomate any workflow | CodespacesInstant dev environments | IssuesPlan and track work | Code ReviewManage code changes | Code QualityEnforce quality at merge | Why GitHub | Marketplace | View all features | Enterprises | Small and medium teams | Startups | View all use cases | View all industries | View all solutions | AI | Software Development | DevOps | Security | View all topics | Customer stories | Events & webinars | Ebooks & reports | Business insights | Trust center | Partners | View all resources

@@ -832,6 +832,11 @@ def test_inf_nan(self):

832832self.assertRaises(TypeError, round, NAN, "ceci n'est pas un integer")

833833self.assertRaises(TypeError, round, -0.0, 1j)

834834835+deftest_inf_nan_ndigits(self):

836+self.assertEqual(round(INF, 0), INF)

837+self.assertEqual(round(-INF, 0), -INF)

838+self.assertTrue(math.isnan(round(NAN, 0)))

839+835840deftest_large_n(self):

836841fornin [324, 325, 400, 2**31-1, 2**31, 2**32, 2**100]:

837842self.assertEqual(round(123.456, n), 123.456)