Back to index

python3.2  3.2.2
Public Member Functions | Static Public Attributes
test.json_tests.test_decode.TestCDecode Class Reference
Inheritance diagram for test.json_tests.test_decode.TestCDecode:
Inheritance graph
[legend]
Collaboration diagram for test.json_tests.test_decode.TestCDecode:
Collaboration graph
[legend]

List of all members.

Public Member Functions

def test_decimal
def test_float
def test_empty_objects
def test_object_pairs_hook
def test_decoder_optimizations
def check_keys_reuse
def test_keys_reuse

Static Public Attributes

 json = cjson
tuple loads = staticmethod(cjson.loads)
tuple dumps = staticmethod(cjson.dumps)

Detailed Description

Definition at line 59 of file test_decode.py.


Member Function Documentation

def test.json_tests.test_decode.TestDecode.check_keys_reuse (   self,
  source,
  loads 
) [inherited]

Definition at line 46 of file test_decode.py.

00046 
00047     def check_keys_reuse(self, source, loads):
00048         rval = loads(source)
00049         (a, b), (c, d) = sorted(rval[0]), sorted(rval[1])
00050         self.assertIs(a, c)
00051         self.assertIs(b, d)

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 8 of file test_decode.py.

00008 
00009     def test_decimal(self):
00010         rval = self.loads('1.1', parse_float=decimal.Decimal)
00011         self.assertTrue(isinstance(rval, decimal.Decimal))
00012         self.assertEqual(rval, decimal.Decimal('1.1'))

Here is the call graph for this function:

Definition at line 39 of file test_decode.py.

00039 
00040     def test_decoder_optimizations(self):
00041         # Several optimizations were made that skip over calls to
00042         # the whitespace regex, so this test is designed to try and
00043         # exercise the uncommon cases. The array cases are already covered.
00044         rval = self.loads('{   "key"    :    "value"    ,  "k":"v"    }')
00045         self.assertEqual(rval, {"key":"value", "k":"v"})

Here is the call graph for this function:

Definition at line 18 of file test_decode.py.

00018 
00019     def test_empty_objects(self):
00020         self.assertEqual(self.loads('{}'), {})
00021         self.assertEqual(self.loads('[]'), [])
00022         self.assertEqual(self.loads('""'), "")

Here is the call graph for this function:

Definition at line 13 of file test_decode.py.

00013 
00014     def test_float(self):
00015         rval = self.loads('1', parse_int=float)
00016         self.assertTrue(isinstance(rval, float))
00017         self.assertEqual(rval, 1.0)

Here is the call graph for this function:

Definition at line 52 of file test_decode.py.

00052 
00053     def test_keys_reuse(self):
00054         s = '[{"a_key": 1, "b_\xe9": 2}, {"a_key": 3, "b_\xe9": 4}]'
00055         self.check_keys_reuse(s, self.loads)
00056         self.check_keys_reuse(s, self.json.decoder.JSONDecoder().decode)
00057 

Here is the call graph for this function:

Definition at line 23 of file test_decode.py.

00023 
00024     def test_object_pairs_hook(self):
00025         s = '{"xkd":1, "kcw":2, "art":3, "hxm":4, "qrt":5, "pad":6, "hoy":7}'
00026         p = [("xkd", 1), ("kcw", 2), ("art", 3), ("hxm", 4),
00027              ("qrt", 5), ("pad", 6), ("hoy", 7)]
00028         self.assertEqual(self.loads(s), eval(s))
00029         self.assertEqual(self.loads(s, object_pairs_hook = lambda x: x), p)
00030         self.assertEqual(self.json.load(StringIO(s),
00031                                         object_pairs_hook=lambda x: x), p)
00032         od = self.loads(s, object_pairs_hook = OrderedDict)
00033         self.assertEqual(od, OrderedDict(p))
00034         self.assertEqual(type(od), OrderedDict)
00035         # the object_pairs_hook takes priority over the object_hook
00036         self.assertEqual(self.loads(s, object_pairs_hook = OrderedDict,
00037                                     object_hook = lambda x: None),
00038                          OrderedDict(p))

Here is the call graph for this function:


Member Data Documentation

tuple test.json_tests.CTest.dumps = staticmethod(cjson.dumps) [static, inherited]

Definition at line 24 of file __init__.py.

test.json_tests.CTest.json = cjson [static, inherited]

Definition at line 22 of file __init__.py.

tuple test.json_tests.CTest.loads = staticmethod(cjson.loads) [static, inherited]

Definition at line 23 of file __init__.py.


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