|
8 | 8 | import unittest |
9 | 9 |
|
10 | 10 | from test import support |
| 11 | +from test.support import import_helper |
11 | 12 | from test.support.testcase import FloatsAreIdenticalMixin |
12 | 13 | from test.support.numbers import ( |
13 | 14 | VALID_UNDERSCORE_LITERALS, |
@@ -670,6 +671,18 @@ def __neg__(self): |
670 | 671 | self.assertFalse(f >= i) |
671 | 672 |
|
672 | 673 |
|
| 674 | +@unittest.skipUnless(hasattr(float, "__getformat__"), "requires __getformat__") |
| 675 | +class FormatFunctionsTestCase(unittest.TestCase): |
| 676 | + @warnings_helper.ignore_warnings(category=DeprecationWarning) |
| 677 | + def test_getformat(self): |
| 678 | + self.assertIn(float.__getformat__('double'), |
| 679 | + ['unknown', 'IEEE, big-endian', 'IEEE, little-endian']) |
| 680 | + self.assertIn(float.__getformat__('float'), |
| 681 | + ['unknown', 'IEEE, big-endian', 'IEEE, little-endian']) |
| 682 | + self.assertRaises(ValueError, float.__getformat__, 'chicken') |
| 683 | + self.assertRaises(TypeError, float.__getformat__, 1) |
| 684 | + |
| 685 | + |
673 | 686 | BE_DOUBLE_INF = b'\x7f\xf0\x00\x00\x00\x00\x00\x00' |
674 | 687 | LE_DOUBLE_INF = bytes(reversed(BE_DOUBLE_INF)) |
675 | 688 | BE_DOUBLE_NAN = b'\x7f\xf8\x00\x00\x00\x00\x00\x00' |
|
0 commit comments