Initial checkin.
[clinton/xbmc-groove.git] / resources / lib / simplejson / tests / test_indent.py
1 from unittest import TestCase
2
3 import simplejson as json
4 import textwrap
5
6 class TestIndent(TestCase):
7 def test_indent(self):
8 h = [['blorpie'], ['whoops'], [], 'd-shtaeou', 'd-nthiouh', 'i-vhbjkhnth',
9 {'nifty': 87}, {'field': 'yes', 'morefield': False} ]
10
11 expect = textwrap.dedent("""\
12 [
13 [
14 "blorpie"
15 ],
16 [
17 "whoops"
18 ],
19 [],
20 "d-shtaeou",
21 "d-nthiouh",
22 "i-vhbjkhnth",
23 {
24 "nifty": 87
25 },
26 {
27 "field": "yes",
28 "morefield": false
29 }
30 ]""")
31
32
33 d1 = json.dumps(h)
34 d2 = json.dumps(h, indent=2, sort_keys=True, separators=(',', ': '))
35
36 h1 = json.loads(d1)
37 h2 = json.loads(d2)
38
39 self.assertEquals(h1, h)
40 self.assertEquals(h2, h)
41 self.assertEquals(d2, expect)