8
8
import simplejson as json
9
9
import math
10
10
import pytest
11
- import platform
12
- import sys
13
11
import time
14
12
import datetime
15
13
import calendar
25
23
import pandas .util .testing as tm
26
24
27
25
28
- def _skip_if_python_ver (skip_major , skip_minor = None ):
29
- major , minor = sys .version_info [:2 ]
30
- if major == skip_major and (skip_minor is None or minor == skip_minor ):
31
- pytest .skip ("skipping Python version %d.%d" % (major , minor ))
32
-
33
-
34
26
json_unicode = (json .dumps if compat .PY3
35
27
else partial (json .dumps , encoding = "utf-8" ))
36
28
37
29
38
30
class UltraJSONTests (TestCase ):
39
31
32
+ @pytest .mark .skipif (compat .is_platform_32bit (),
33
+ reason = "not compliant on 32-bit, xref #15865" )
40
34
def test_encodeDecimal (self ):
41
35
sut = decimal .Decimal ("1337.1337" )
42
36
encoded = ujson .encode (sut , double_precision = 15 )
@@ -153,10 +147,9 @@ def test_decimalDecodeTestPrecise(self):
153
147
decoded = ujson .decode (encoded , precise_float = True )
154
148
self .assertEqual (sut , decoded )
155
149
150
+ @pytest .mark .skipif (compat .is_platform_windows () and not compat .PY3 ,
151
+ reason = "buggy on win-64 for py2" )
156
152
def test_encodeDoubleTinyExponential (self ):
157
- if compat .is_platform_windows () and not compat .PY3 :
158
- pytest .skip ("buggy on win-64 for py2" )
159
-
160
153
num = 1e-40
161
154
self .assertEqual (num , ujson .decode (ujson .encode (num )))
162
155
num = 1e-100
@@ -275,8 +268,6 @@ def test_encodeUnicodeConversion2(self):
275
268
self .assertEqual (dec , json .loads (enc ))
276
269
277
270
def test_encodeUnicodeSurrogatePair (self ):
278
- _skip_if_python_ver (2 , 5 )
279
- _skip_if_python_ver (2 , 6 )
280
271
input = "\xf0 \x90 \x8d \x86 "
281
272
enc = ujson .encode (input )
282
273
dec = ujson .decode (enc )
@@ -285,8 +276,6 @@ def test_encodeUnicodeSurrogatePair(self):
285
276
self .assertEqual (dec , json .loads (enc ))
286
277
287
278
def test_encodeUnicode4BytesUTF8 (self ):
288
- _skip_if_python_ver (2 , 5 )
289
- _skip_if_python_ver (2 , 6 )
290
279
input = "\xf0 \x91 \x80 \xb0 TRAILINGNORMAL"
291
280
enc = ujson .encode (input )
292
281
dec = ujson .decode (enc )
@@ -295,8 +284,6 @@ def test_encodeUnicode4BytesUTF8(self):
295
284
self .assertEqual (dec , json .loads (enc ))
296
285
297
286
def test_encodeUnicode4BytesUTF8Highest (self ):
298
- _skip_if_python_ver (2 , 5 )
299
- _skip_if_python_ver (2 , 6 )
300
287
input = "\xf3 \xbf \xbf \xbf TRAILINGNORMAL"
301
288
enc = ujson .encode (input )
302
289
@@ -462,7 +449,6 @@ def test_datetime_units(self):
462
449
self .assertRaises (ValueError , ujson .encode , val , date_unit = 'foo' )
463
450
464
451
def test_encodeToUTF8 (self ):
465
- _skip_if_python_ver (2 , 5 )
466
452
input = "\xe6 \x97 \xa5 \xd1 \x88 "
467
453
enc = ujson .encode (input , ensure_ascii = False )
468
454
dec = ujson .decode (enc )
@@ -696,8 +682,8 @@ def test_decodeNumericIntNeg(self):
696
682
input = "-31337"
697
683
self .assertEqual (- 31337 , ujson .decode (input ))
698
684
685
+ @pytest .mark .skipif (compat .PY3 , reason = "only PY2" )
699
686
def test_encodeUnicode4BytesUTF8Fail (self ):
700
- _skip_if_python_ver (3 )
701
687
input = "\xfd \xbf \xbf \xbf \xbf \xbf "
702
688
try :
703
689
enc = ujson .encode (input ) # noqa
@@ -1029,7 +1015,7 @@ def testIntMax(self):
1029
1015
num = np .uint32 (np .iinfo (np .uint32 ).max )
1030
1016
self .assertEqual (np .uint32 (ujson .decode (ujson .encode (num ))), num )
1031
1017
1032
- if platform . architecture ()[ 0 ] != '32bit' :
1018
+ if not compat . is_platform_32bit () :
1033
1019
num = np .int64 (np .iinfo (np .int64 ).max )
1034
1020
self .assertEqual (np .int64 (ujson .decode (ujson .encode (num ))), num )
1035
1021
0 commit comments