Skip to content

Commit 42c3783

Browse files
committed
redo on top of python#121071
1 parent 6d18f0a commit 42c3783

File tree

1 file changed

+1
-23
lines changed

1 file changed

+1
-23
lines changed

Lib/test/test_float.py

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -863,29 +863,7 @@ def test_short_repr(self):
863863
self.assertEqual(repr(float(negs)), str(float(negs)))
864864

865865
@support.requires_IEEE_754
866-
class RoundTestCase(unittest.TestCase):
867-
868-
def assertFloatsAreIdentical(self, x, y):
869-
"""Fail unless floats x and y are identical, in the sense that:
870-
(1) both x and y are nans, or
871-
(2) both x and y are infinities, with the same sign, or
872-
(3) both x and y are zeros, with the same sign, or
873-
(4) x and y are both finite and nonzero, and x == y
874-
"""
875-
msg = 'floats {!r} and {!r} are not identical'
876-
877-
if isnan(x) or isnan(y):
878-
if isnan(x) and isnan(y):
879-
return
880-
elif x == y:
881-
if x != 0.0:
882-
return
883-
# both zero; check that signs match
884-
elif copysign(1.0, x) == copysign(1.0, y):
885-
return
886-
else:
887-
msg += ': zeros have different signs'
888-
self.fail(msg.format(x, y))
866+
class RoundTestCase(unittest.TestCase, FloatsAreIdenticalMixin):
889867

890868
def test_inf_nan(self):
891869
self.assertRaises(OverflowError, round, INF)

0 commit comments

Comments
 (0)