77from test .test_capi .test_getargs import (Float , FloatSubclass , FloatSubclass2 ,
88 BadIndex2 , BadFloat2 , Index , BadIndex ,
99 BadFloat )
10+ from test import support
1011from test .support import import_helper
1112
1213_testcapi = import_helper .import_module ('_testcapi' )
2324 8 : 2.0 ** - 53 , # binary64
2425}
2526
26- HAVE_IEEE_754 = float .__getformat__ ("double" ).startswith ("IEEE" )
2727INF = float ("inf" )
2828NAN = float ("nan" )
2929
@@ -170,14 +170,13 @@ def test_unpack(self):
170170 self .assertEqual (unpack (b'\x00 \x00 \x00 \x00 \x00 \x00 \xf8 ?' , LITTLE_ENDIAN ),
171171 1.5 )
172172
173+ @support .requires_IEEE_754
173174 def test_pack_unpack_roundtrip (self ):
174175 pack = _testcapi .float_pack
175176 unpack = _testcapi .float_unpack
176177
177178 large = 2.0 ** 100
178- values = [1.0 , 1.5 , large , 1.0 / 7 , math .pi ]
179- if HAVE_IEEE_754 :
180- values .extend ((INF , NAN ))
179+ values = [1.0 , 1.5 , large , 1.0 / 7 , math .pi , INF , NAN ]
181180 for value in values :
182181 for size in (2 , 4 , 8 ,):
183182 if size == 2 and value == large :
@@ -196,7 +195,7 @@ def test_pack_unpack_roundtrip(self):
196195 else :
197196 self .assertEqual (value2 , value )
198197
199- @unittest . skipUnless ( HAVE_IEEE_754 , "requires IEEE 754" )
198+ @support . requires_IEEE_754
200199 def test_pack_unpack_roundtrip_for_nans (self ):
201200 pack = _testcapi .float_pack
202201 unpack = _testcapi .float_unpack
@@ -228,7 +227,7 @@ def test_pack_unpack_roundtrip_for_nans(self):
228227 self .assertTrue (math .isnan (value ))
229228 self .assertEqual (data1 , data2 )
230229
231- @unittest . skipUnless ( HAVE_IEEE_754 , "requires IEEE 754" )
230+ @support . requires_IEEE_754
232231 @unittest .skipUnless (sys .maxsize != 2147483647 , "requires 64-bit mode" )
233232 def test_pack_unpack_nans_for_different_formats (self ):
234233 pack = _testcapi .float_pack
0 commit comments