diff options
author | Benjamin Peterson <benjamin@python.org> | 2009-05-02 12:36:44 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2009-05-02 12:36:44 (GMT) |
commit | c6b607d4a9e4d60fb506034ce67fc89734bb68a7 (patch) | |
tree | b4f27e81ab25a9dfe6a97433f4d25c263b59f6cc /Lib/json/tests/test_encode_basestring_ascii.py | |
parent | 7255f18556ae70fc28b563a345577d3ec8f6f0ba (diff) | |
download | cpython-c6b607d4a9e4d60fb506034ce67fc89734bb68a7.zip cpython-c6b607d4a9e4d60fb506034ce67fc89734bb68a7.tar.gz cpython-c6b607d4a9e4d60fb506034ce67fc89734bb68a7.tar.bz2 |
port simplejson upgrade from the trunk #4136
json also now works only with unicode strings
Patch by Antoine Pitrou; updated by me
Diffstat (limited to 'Lib/json/tests/test_encode_basestring_ascii.py')
-rw-r--r-- | Lib/json/tests/test_encode_basestring_ascii.py | 40 |
1 files changed, 20 insertions, 20 deletions
diff --git a/Lib/json/tests/test_encode_basestring_ascii.py b/Lib/json/tests/test_encode_basestring_ascii.py index 4517ae9..68ce7ef 100644 --- a/Lib/json/tests/test_encode_basestring_ascii.py +++ b/Lib/json/tests/test_encode_basestring_ascii.py @@ -3,22 +3,20 @@ from unittest import TestCase import json.encoder CASES = [ - ('/\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\x08\x0c\n\r\t`1~!@#$%^&*()_+-=[]{}|;:\',./<>?', b'"/\\\\\\"\\ucafe\\ubabe\\uab98\\ufcde\\ubcda\\uef4a\\b\\f\\n\\r\\t`1~!@#$%^&*()_+-=[]{}|;:\',./<>?"'), - ('\u0123\u4567\u89ab\ucdef\uabcd\uef4a', b'"\\u0123\\u4567\\u89ab\\ucdef\\uabcd\\uef4a"'), - ('controls', b'"controls"'), - ('\x08\x0c\n\r\t', b'"\\b\\f\\n\\r\\t"'), - ('{"object with 1 member":["array with 1 element"]}', b'"{\\"object with 1 member\\":[\\"array with 1 element\\"]}"'), - (' s p a c e d ', b'" s p a c e d "'), - ('\U0001d120', b'"\\ud834\\udd20"'), - ('\u03b1\u03a9', b'"\\u03b1\\u03a9"'), - (b'\xce\xb1\xce\xa9', b'"\\u03b1\\u03a9"'), - ('\u03b1\u03a9', b'"\\u03b1\\u03a9"'), - (b'\xce\xb1\xce\xa9', b'"\\u03b1\\u03a9"'), - ('\u03b1\u03a9', b'"\\u03b1\\u03a9"'), - ('\u03b1\u03a9', b'"\\u03b1\\u03a9"'), - ("`1~!@#$%^&*()_+-={':[,]}|;.</>?", b'"`1~!@#$%^&*()_+-={\':[,]}|;.</>?"'), - ('\x08\x0c\n\r\t', b'"\\b\\f\\n\\r\\t"'), - ('\u0123\u4567\u89ab\ucdef\uabcd\uef4a', b'"\\u0123\\u4567\\u89ab\\ucdef\\uabcd\\uef4a"'), + ('/\\"\ucafe\ubabe\uab98\ufcde\ubcda\uef4a\x08\x0c\n\r\t`1~!@#$%^&*()_+-=[]{}|;:\',./<>?', '"/\\\\\\"\\ucafe\\ubabe\\uab98\\ufcde\\ubcda\\uef4a\\b\\f\\n\\r\\t`1~!@#$%^&*()_+-=[]{}|;:\',./<>?"'), + ('\u0123\u4567\u89ab\ucdef\uabcd\uef4a', '"\\u0123\\u4567\\u89ab\\ucdef\\uabcd\\uef4a"'), + ('controls', '"controls"'), + ('\x08\x0c\n\r\t', '"\\b\\f\\n\\r\\t"'), + ('{"object with 1 member":["array with 1 element"]}', '"{\\"object with 1 member\\":[\\"array with 1 element\\"]}"'), + (' s p a c e d ', '" s p a c e d "'), + ('\U0001d120', '"\\ud834\\udd20"'), + ('\u03b1\u03a9', '"\\u03b1\\u03a9"'), + ('\u03b1\u03a9', '"\\u03b1\\u03a9"'), + ('\u03b1\u03a9', '"\\u03b1\\u03a9"'), + ('\u03b1\u03a9', '"\\u03b1\\u03a9"'), + ("`1~!@#$%^&*()_+-={':[,]}|;.</>?", '"`1~!@#$%^&*()_+-={\':[,]}|;.</>?"'), + ('\x08\x0c\n\r\t', '"\\b\\f\\n\\r\\t"'), + ('\u0123\u4567\u89ab\ucdef\uabcd\uef4a', '"\\u0123\\u4567\\u89ab\\ucdef\\uabcd\\uef4a"'), ] class TestEncodeBaseStringAscii(TestCase): @@ -26,12 +24,14 @@ class TestEncodeBaseStringAscii(TestCase): self._test_encode_basestring_ascii(json.encoder.py_encode_basestring_ascii) def test_c_encode_basestring_ascii(self): - if json.encoder.c_encode_basestring_ascii is not None: - self._test_encode_basestring_ascii(json.encoder.c_encode_basestring_ascii) + if not json.encoder.c_encode_basestring_ascii: + return + self._test_encode_basestring_ascii(json.encoder.c_encode_basestring_ascii) def _test_encode_basestring_ascii(self, encode_basestring_ascii): fname = encode_basestring_ascii.__name__ for input_string, expect in CASES: result = encode_basestring_ascii(input_string) - result = result.encode("ascii") - self.assertEquals(result, expect) + self.assertEquals(result, expect, + '{0!r} != {1!r} for {2}({3!r})'.format( + result, expect, fname, input_string)) |