66from test .support import import_helper
77from test .support import script_helper
88from test .support import warnings_helper
9+ from test .support .testcase import FloatsAreIdenticalMixin
910# Skip this test if the _testcapi module isn't available.
1011_testcapi = import_helper .import_module ('_testcapi' )
1112from _testcapi import getargs_keywords , getargs_keyword_only
@@ -436,11 +437,7 @@ def test_K(self):
436437 self .assertEqual (VERY_LARGE & ULLONG_MAX , getargs_K (VERY_LARGE ))
437438
438439
439- class Float_TestCase (unittest .TestCase ):
440- def assertEqualWithSign (self , actual , expected ):
441- self .assertEqual (actual , expected )
442- self .assertEqual (math .copysign (1 , actual ), math .copysign (1 , expected ))
443-
440+ class Float_TestCase (unittest .TestCase , FloatsAreIdenticalMixin ):
444441 def test_f (self ):
445442 from _testcapi import getargs_f
446443 self .assertEqual (getargs_f (4.25 ), 4.25 )
@@ -462,10 +459,10 @@ def test_f(self):
462459 self .assertEqual (getargs_f (DBL_MAX ), INF )
463460 self .assertEqual (getargs_f (- DBL_MAX ), - INF )
464461 if FLT_MIN > DBL_MIN :
465- self .assertEqualWithSign (getargs_f (DBL_MIN ), 0.0 )
466- self .assertEqualWithSign (getargs_f (- DBL_MIN ), - 0.0 )
467- self .assertEqualWithSign (getargs_f (0.0 ), 0.0 )
468- self .assertEqualWithSign (getargs_f (- 0.0 ), - 0.0 )
462+ self .assertFloatsAreIdentical (getargs_f (DBL_MIN ), 0.0 )
463+ self .assertFloatsAreIdentical (getargs_f (- DBL_MIN ), - 0.0 )
464+ self .assertFloatsAreIdentical (getargs_f (0.0 ), 0.0 )
465+ self .assertFloatsAreIdentical (getargs_f (- 0.0 ), - 0.0 )
469466 r = getargs_f (NAN )
470467 self .assertNotEqual (r , r )
471468
@@ -494,8 +491,8 @@ def test_d(self):
494491 self .assertEqual (getargs_d (x ), x )
495492 self .assertRaises (OverflowError , getargs_d , 1 << DBL_MAX_EXP )
496493 self .assertRaises (OverflowError , getargs_d , - 1 << DBL_MAX_EXP )
497- self .assertEqualWithSign (getargs_d (0.0 ), 0.0 )
498- self .assertEqualWithSign (getargs_d (- 0.0 ), - 0.0 )
494+ self .assertFloatsAreIdentical (getargs_d (0.0 ), 0.0 )
495+ self .assertFloatsAreIdentical (getargs_d (- 0.0 ), - 0.0 )
499496 r = getargs_d (NAN )
500497 self .assertNotEqual (r , r )
501498
@@ -519,10 +516,10 @@ def test_D(self):
519516 self .assertEqual (getargs_D (c ), c )
520517 c = complex (1.0 , x )
521518 self .assertEqual (getargs_D (c ), c )
522- self .assertEqualWithSign (getargs_D (complex (0.0 , 1.0 )).real , 0.0 )
523- self .assertEqualWithSign (getargs_D (complex (- 0.0 , 1.0 )).real , - 0.0 )
524- self .assertEqualWithSign (getargs_D (complex (1.0 , 0.0 )).imag , 0.0 )
525- self .assertEqualWithSign (getargs_D (complex (1.0 , - 0.0 )).imag , - 0.0 )
519+ self .assertFloatsAreIdentical (getargs_D (complex (0.0 , 1.0 )).real , 0.0 )
520+ self .assertFloatsAreIdentical (getargs_D (complex (- 0.0 , 1.0 )).real , - 0.0 )
521+ self .assertFloatsAreIdentical (getargs_D (complex (1.0 , 0.0 )).imag , 0.0 )
522+ self .assertFloatsAreIdentical (getargs_D (complex (1.0 , - 0.0 )).imag , - 0.0 )
526523
527524
528525class Paradox :
0 commit comments