Skip to content

Commit 97cef6c

Browse files
wesmChang She
authored and
Chang She
committed
TST: skip failing UJSON tests on Python 2.5
1 parent cf907c8 commit 97cef6c

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

pandas/src/ujson/python/objToJSON.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1084,17 +1084,17 @@ void Object_beginTypeContext (JSOBJ _obj, JSONTypeContext *tc)
10841084
return;
10851085
}
10861086
else
1087-
if (PyUnicode_Check(obj))
1087+
if (PyString_Check(obj))
10881088
{
10891089
PRINTMARK();
1090-
pc->PyTypeToJSON = PyUnicodeToUTF8; tc->type = JT_UTF8;
1090+
pc->PyTypeToJSON = PyStringToUTF8; tc->type = JT_UTF8;
10911091
return;
10921092
}
10931093
else
1094-
if (PyString_Check(obj))
1094+
if (PyUnicode_Check(obj))
10951095
{
10961096
PRINTMARK();
1097-
pc->PyTypeToJSON = PyStringToUTF8; tc->type = JT_UTF8;
1097+
pc->PyTypeToJSON = PyUnicodeToUTF8; tc->type = JT_UTF8;
10981098
return;
10991099
}
11001100
else

pandas/tests/test_ujson.py

+12
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import simplejson as json
1010
import math
1111
import platform
12+
import sys
1213
import time
1314
import datetime
1415
import calendar
@@ -21,6 +22,13 @@
2122
from pandas import DataFrame, Series, Index
2223
import pandas.util.testing as tm
2324

25+
26+
def _skip_if_python25():
27+
import nose
28+
major, minor = sys.version_info[:2]
29+
if major == 2 and minor == 5:
30+
raise nose.SkipTest
31+
2432
class UltraJSONTests(TestCase):
2533
def test_encodeDictWithUnicodeKeys(self):
2634
input = { u"key1": u"value1", u"key1": u"value1", u"key1": u"value1", u"key1": u"value1", u"key1": u"value1", u"key1": u"value1" }
@@ -135,6 +143,7 @@ def test_encodeUnicodeConversion2(self):
135143
self.assertEquals(dec, json.loads(enc))
136144

137145
def test_encodeUnicodeSurrogatePair(self):
146+
_skip_if_python25()
138147
input = "\xf0\x90\x8d\x86"
139148
enc = ujson.encode(input)
140149
dec = ujson.decode(enc)
@@ -143,6 +152,7 @@ def test_encodeUnicodeSurrogatePair(self):
143152
self.assertEquals(dec, json.loads(enc))
144153

145154
def test_encodeUnicode4BytesUTF8(self):
155+
_skip_if_python25()
146156
input = "\xf0\x91\x80\xb0TRAILINGNORMAL"
147157
enc = ujson.encode(input)
148158
dec = ujson.decode(enc)
@@ -151,6 +161,7 @@ def test_encodeUnicode4BytesUTF8(self):
151161
self.assertEquals(dec, json.loads(enc))
152162

153163
def test_encodeUnicode4BytesUTF8Highest(self):
164+
_skip_if_python25()
154165
input = "\xf3\xbf\xbf\xbfTRAILINGNORMAL"
155166
enc = ujson.encode(input)
156167

@@ -270,6 +281,7 @@ def test_datetime_nanosecond_unit(self):
270281
self.assert_(roundtrip == stamp.value)
271282

272283
def test_encodeToUTF8(self):
284+
_skip_if_python25()
273285
input = "\xe6\x97\xa5\xd1\x88"
274286
enc = ujson.encode(input, ensure_ascii=False)
275287
dec = ujson.decode(enc)

0 commit comments

Comments
 (0)