diff options
author | Bob Ippolito <bob@redivi.com> | 2018-04-24 13:36:18 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-24 13:36:18 -0700 |
commit | 2ec708bbc884b956c453eb057547cf0150294be9 (patch) | |
tree | 83c2c4089adc8210b16ffad1e612a09618c88078 /simplejson/tests | |
parent | 2cd78252932f41a665deaf0ce8f194723c91919c (diff) | |
parent | 51b69877435b8503b0400eb54461cded7f103ecb (diff) | |
download | simplejson-2ec708bbc884b956c453eb057547cf0150294be9.tar.gz |
Merge pull request #215 from simplejson/compat
Simplify the compatibility code.
Diffstat (limited to 'simplejson/tests')
-rw-r--r-- | simplejson/tests/test_dump.py | 4 | ||||
-rw-r--r-- | simplejson/tests/test_errors.py | 4 | ||||
-rw-r--r-- | simplejson/tests/test_str_subclass.py | 4 | ||||
-rw-r--r-- | simplejson/tests/test_unicode.py | 4 |
4 files changed, 8 insertions, 8 deletions
diff --git a/simplejson/tests/test_dump.py b/simplejson/tests/test_dump.py index f5f4c1f..2a30125 100644 --- a/simplejson/tests/test_dump.py +++ b/simplejson/tests/test_dump.py @@ -1,5 +1,5 @@ from unittest import TestCase -from simplejson.compat import StringIO, long_type, b, binary_type, text_type, PY3 +from simplejson.compat import StringIO, long_type, b, text_type, PY3 import simplejson as json class MisbehavingTextSubtype(text_type): @@ -7,7 +7,7 @@ class MisbehavingTextSubtype(text_type): return "FAIL!" def as_text_type(s): - if PY3 and isinstance(s, binary_type): + if PY3 and isinstance(s, bytes): return s.decode('ascii') return s diff --git a/simplejson/tests/test_errors.py b/simplejson/tests/test_errors.py index 78f25a5..d573825 100644 --- a/simplejson/tests/test_errors.py +++ b/simplejson/tests/test_errors.py @@ -2,7 +2,7 @@ import sys, pickle from unittest import TestCase import simplejson as json -from simplejson.compat import u, b +from simplejson.compat import text_type, b class TestErrors(TestCase): def test_string_keys_error(self): @@ -41,7 +41,7 @@ class TestErrors(TestCase): def test_scan_error(self): err = None - for t in (u, b): + for t in (text_type, b): try: json.loads(t('{"asdf": "')) except json.JSONDecodeError: diff --git a/simplejson/tests/test_str_subclass.py b/simplejson/tests/test_str_subclass.py index dc87904..b6c8351 100644 --- a/simplejson/tests/test_str_subclass.py +++ b/simplejson/tests/test_str_subclass.py @@ -1,7 +1,7 @@ from unittest import TestCase import simplejson -from simplejson.compat import text_type, u +from simplejson.compat import text_type # Tests for issue demonstrated in https://github.com/simplejson/simplejson/issues/144 class WonkyTextSubclass(text_type): @@ -10,7 +10,7 @@ class WonkyTextSubclass(text_type): class TestStrSubclass(TestCase): def test_dump_load(self): - for s in ['', '"hello"', 'text', u('\u005c')]: + for s in ['', '"hello"', 'text', u'\u005c']: self.assertEqual( s, simplejson.loads(simplejson.dumps(WonkyTextSubclass(s)))) diff --git a/simplejson/tests/test_unicode.py b/simplejson/tests/test_unicode.py index 1c7e95e..0c7b1a6 100644 --- a/simplejson/tests/test_unicode.py +++ b/simplejson/tests/test_unicode.py @@ -3,7 +3,7 @@ import codecs from unittest import TestCase import simplejson as json -from simplejson.compat import unichr, text_type, b, u, BytesIO +from simplejson.compat import unichr, text_type, b, BytesIO class TestUnicode(TestCase): def test_encoding1(self): @@ -93,7 +93,7 @@ class TestUnicode(TestCase): def test_ensure_ascii_false_bytestring_encoding(self): # http://code.google.com/p/simplejson/issues/detail?id=48 doc1 = {u'quux': b('Arr\xc3\xaat sur images')} - doc2 = {u'quux': u('Arr\xeat sur images')} + doc2 = {u'quux': u'Arr\xeat sur images'} doc_ascii = '{"quux": "Arr\\u00eat sur images"}' doc_unicode = u'{"quux": "Arr\xeat sur images"}' self.assertEqual(json.dumps(doc1), doc_ascii) |