summaryrefslogtreecommitdiffstats
path: root/Lib/json/tests/test_encode_basestring_ascii.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/json/tests/test_encode_basestring_ascii.py')
-rw-r--r--Lib/json/tests/test_encode_basestring_ascii.py40
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))