Back to index

python3.2  3.2.2
Public Member Functions
test.json_tests.test_unicode.TestUnicode Class Reference
Inheritance diagram for test.json_tests.test_unicode.TestUnicode:
Inheritance graph
[legend]

List of all members.

Public Member Functions

def test_encoding3
def test_encoding4
def test_encoding5
def test_encoding6
def test_big_unicode_encode
def test_big_unicode_decode
def test_unicode_decode
def test_unicode_preservation
def test_bytes_encode
def test_bytes_decode
def test_object_pairs_hook_with_unicode

Detailed Description

Definition at line 5 of file test_unicode.py.


Member Function Documentation

Definition at line 34 of file test_unicode.py.

00034 
00035     def test_big_unicode_decode(self):
00036         u = 'z\U0001d120x'
00037         self.assertEqual(self.loads('"' + u + '"'), u)
00038         self.assertEqual(self.loads('"z\\ud834\\udd20x"'), u)

Here is the call graph for this function:

Definition at line 29 of file test_unicode.py.

00029 
00030     def test_big_unicode_encode(self):
00031         u = '\U0001d120'
00032         self.assertEqual(self.dumps(u), '"\\ud834\\udd20"')
00033         self.assertEqual(self.dumps(u, ensure_ascii=False), '"\U0001d120"')

Here is the call graph for this function:

Definition at line 54 of file test_unicode.py.

00054 
00055     def test_bytes_decode(self):
00056         self.assertRaises(TypeError, self.loads, b'"hi"')
00057         self.assertRaises(TypeError, self.loads, b'["hi"]')
00058 

Here is the call graph for this function:

Definition at line 50 of file test_unicode.py.

00050 
00051     def test_bytes_encode(self):
00052         self.assertRaises(TypeError, self.dumps, b"hi")
00053         self.assertRaises(TypeError, self.dumps, [b"hi"])

Here is the call graph for this function:

Definition at line 9 of file test_unicode.py.

00009 
00010     def test_encoding3(self):
00011         u = '\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
00012         j = self.dumps(u)
00013         self.assertEqual(j, '"\\u03b1\\u03a9"')

Here is the call graph for this function:

Definition at line 14 of file test_unicode.py.

00014 
00015     def test_encoding4(self):
00016         u = '\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
00017         j = self.dumps([u])
00018         self.assertEqual(j, '["\\u03b1\\u03a9"]')

Here is the call graph for this function:

Definition at line 19 of file test_unicode.py.

00019 
00020     def test_encoding5(self):
00021         u = '\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
00022         j = self.dumps(u, ensure_ascii=False)
00023         self.assertEqual(j, '"{0}"'.format(u))

Here is the call graph for this function:

Definition at line 24 of file test_unicode.py.

00024 
00025     def test_encoding6(self):
00026         u = '\N{GREEK SMALL LETTER ALPHA}\N{GREEK CAPITAL LETTER OMEGA}'
00027         j = self.dumps([u], ensure_ascii=False)
00028         self.assertEqual(j, '["{0}"]'.format(u))

Here is the call graph for this function:

Definition at line 59 of file test_unicode.py.

00059 
00060     def test_object_pairs_hook_with_unicode(self):
00061         s = '{"xkd":1, "kcw":2, "art":3, "hxm":4, "qrt":5, "pad":6, "hoy":7}'
00062         p = [("xkd", 1), ("kcw", 2), ("art", 3), ("hxm", 4),
00063              ("qrt", 5), ("pad", 6), ("hoy", 7)]
00064         self.assertEqual(self.loads(s), eval(s))
00065         self.assertEqual(self.loads(s, object_pairs_hook = lambda x: x), p)
00066         od = self.loads(s, object_pairs_hook = OrderedDict)
00067         self.assertEqual(od, OrderedDict(p))
00068         self.assertEqual(type(od), OrderedDict)
00069         # the object_pairs_hook takes priority over the object_hook
00070         self.assertEqual(self.loads(s, object_pairs_hook = OrderedDict,
00071                                     object_hook = lambda x: None),
00072                          OrderedDict(p))
00073 

Here is the call graph for this function:

Definition at line 39 of file test_unicode.py.

00039 
00040     def test_unicode_decode(self):
00041         for i in range(0, 0xd7ff):
00042             u = chr(i)
00043             s = '"\\u{0:04x}"'.format(i)
00044             self.assertEqual(self.loads(s), u)

Here is the call graph for this function:

Definition at line 45 of file test_unicode.py.

00045 
00046     def test_unicode_preservation(self):
00047         self.assertEqual(type(self.loads('""')), str)
00048         self.assertEqual(type(self.loads('"a"')), str)
00049         self.assertEqual(type(self.loads('["a"]')[0]), str)

Here is the call graph for this function:


The documentation for this class was generated from the following file: