diff options
Diffstat (limited to 'Lib/test/test_float.py')
-rw-r--r-- | Lib/test/test_float.py | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/Lib/test/test_float.py b/Lib/test/test_float.py index 4d7bbba..502292f 100644 --- a/Lib/test/test_float.py +++ b/Lib/test/test_float.py @@ -88,7 +88,7 @@ class GeneralFloatCases(unittest.TestCase): self.assertRaises(ValueError, float, " -0x3.p-1 ") self.assertRaises(ValueError, float, " +0x3.p-1 ") self.assertEqual(float(" 25.e-1 "), 2.5) - self.assertEqual(support.fcmp(float(" .25e-1 "), .025), 0) + self.assertAlmostEqual(float(" .25e-1 "), .025) def test_floatconversion(self): # Make sure that calls to __float__() work properly @@ -860,15 +860,18 @@ class InfNanTest(unittest.TestCase): self.assertEqual(str(1e300 * 1e300 * 0), "nan") self.assertEqual(str(-1e300 * 1e300 * 0), "nan") - def notest_float_nan(self): - self.assertTrue(NAN.is_nan()) - self.assertFalse(INF.is_nan()) - self.assertFalse((0.).is_nan()) + def test_inf_signs(self): + self.assertEqual(copysign(1.0, float('inf')), 1.0) + self.assertEqual(copysign(1.0, float('-inf')), -1.0) + + @unittest.skipUnless(getattr(sys, 'float_repr_style', '') == 'short', + "applies only when using short float repr style") + def test_nan_signs(self): + # When using the dtoa.c code, the sign of float('nan') should + # be predictable. + self.assertEqual(copysign(1.0, float('nan')), 1.0) + self.assertEqual(copysign(1.0, float('-nan')), -1.0) - def notest_float_inf(self): - self.assertTrue(INF.is_inf()) - self.assertFalse(NAN.is_inf()) - self.assertFalse((0.).is_inf()) fromHex = float.fromhex toHex = float.hex |