Skip to content

Commit 3a4c818

Browse files
committed
address review: restore test_getformat()
1 parent e38e308 commit 3a4c818

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

Lib/test/test_float.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import unittest
99

1010
from test import support
11+
from test.support import import_helper
1112
from test.support.testcase import FloatsAreIdenticalMixin
1213
from test.support.numbers import (
1314
VALID_UNDERSCORE_LITERALS,
@@ -670,6 +671,18 @@ def __neg__(self):
670671
self.assertFalse(f >= i)
671672

672673

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+
673686
BE_DOUBLE_INF = b'\x7f\xf0\x00\x00\x00\x00\x00\x00'
674687
LE_DOUBLE_INF = bytes(reversed(BE_DOUBLE_INF))
675688
BE_DOUBLE_NAN = b'\x7f\xf8\x00\x00\x00\x00\x00\x00'

0 commit comments

Comments
 (0)