From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Mon, 30 Sep 2024 04:22:13 +0000 (+0200) Subject: [3.13] gh-123811: test that round() can return signed zero (GH-123829) (#123938) X-Git-Tag: v3.13.0rc3~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=243db20b75e6c127bb8bd2d42099ba16a5fc56e1;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-123811: test that round() can return signed zero (GH-123829) (#123938) gh-123811: test that round() can return signed zero (GH-123829) (cherry picked from commit d2b9b6f919e92184420c8e13d078e83447ce7917) Co-authored-by: Sergey B Kirpichev --- diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py index ebe026eb910e..65b9cb03e616 100644 --- a/Lib/test/test_float.py +++ b/Lib/test/test_float.py @@ -830,7 +830,7 @@ class ReprTestCase(unittest.TestCase): self.assertEqual(repr(float(negs)), str(float(negs))) @support.requires_IEEE_754 -class RoundTestCase(unittest.TestCase): +class RoundTestCase(unittest.TestCase, FloatsAreIdenticalMixin): def test_inf_nan(self): self.assertRaises(OverflowError, round, INF) @@ -860,10 +860,10 @@ class RoundTestCase(unittest.TestCase): def test_small_n(self): for n in [-308, -309, -400, 1-2**31, -2**31, -2**31-1, -2**100]: - self.assertEqual(round(123.456, n), 0.0) - self.assertEqual(round(-123.456, n), -0.0) - self.assertEqual(round(1e300, n), 0.0) - self.assertEqual(round(1e-320, n), 0.0) + self.assertFloatsAreIdentical(round(123.456, n), 0.0) + self.assertFloatsAreIdentical(round(-123.456, n), -0.0) + self.assertFloatsAreIdentical(round(1e300, n), 0.0) + self.assertFloatsAreIdentical(round(1e-320, n), 0.0) def test_overflow(self): self.assertRaises(OverflowError, round, 1.6e308, -308)