mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-46852: Restore test_getformat() test (GH-31601)
This commit is contained in:
parent
ad56919c5e
commit
5a1c637ec6
1 changed files with 11 additions and 3 deletions
|
@ -16,9 +16,6 @@ from math import isinf, isnan, copysign, ldexp
|
|||
INF = float("inf")
|
||||
NAN = float("nan")
|
||||
|
||||
have_getformat = hasattr(float, "__getformat__")
|
||||
requires_getformat = unittest.skipUnless(have_getformat,
|
||||
"requires __getformat__")
|
||||
|
||||
#locate file with float format test values
|
||||
test_dir = os.path.dirname(__file__) or os.curdir
|
||||
|
@ -610,6 +607,17 @@ class GeneralFloatCases(unittest.TestCase):
|
|||
self.assertEqual(hash(value), object.__hash__(value))
|
||||
|
||||
|
||||
@unittest.skipUnless(hasattr(float, "__getformat__"), "requires __getformat__")
|
||||
class FormatFunctionsTestCase(unittest.TestCase):
|
||||
def test_getformat(self):
|
||||
self.assertIn(float.__getformat__('double'),
|
||||
['unknown', 'IEEE, big-endian', 'IEEE, little-endian'])
|
||||
self.assertIn(float.__getformat__('float'),
|
||||
['unknown', 'IEEE, big-endian', 'IEEE, little-endian'])
|
||||
self.assertRaises(ValueError, float.__getformat__, 'chicken')
|
||||
self.assertRaises(TypeError, float.__getformat__, 1)
|
||||
|
||||
|
||||
BE_DOUBLE_INF = b'\x7f\xf0\x00\x00\x00\x00\x00\x00'
|
||||
LE_DOUBLE_INF = bytes(reversed(BE_DOUBLE_INF))
|
||||
BE_DOUBLE_NAN = b'\x7f\xf8\x00\x00\x00\x00\x00\x00'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue