1
from unittest import TestCase
3
import simplejson as json
6
class TestIndent(TestCase):
8
h = [['blorpie'], ['whoops'], [], 'd-shtaeou', 'd-nthiouh',
10
{'nifty': 87}, {'field': 'yes', 'morefield': False} ]
12
expect = textwrap.dedent("""\
29
\t\t"morefield": false
35
d2 = json.dumps(h, indent='\t', sort_keys=True, separators=(',', ': '))
36
d3 = json.dumps(h, indent=' ', sort_keys=True, separators=(',', ': '))
37
d4 = json.dumps(h, indent=2, sort_keys=True, separators=(',', ': '))
44
self.assertEquals(h1, h)
45
self.assertEquals(h2, h)
46
self.assertEquals(h3, h)
47
self.assertEquals(h4, h)
48
self.assertEquals(d3, expect.replace('\t', ' '))
49
self.assertEquals(d4, expect.replace('\t', ' '))
50
# NOTE: Python 2.4 textwrap.dedent converts tabs to spaces,
51
# so the following is expected to fail. Python 2.4 is not a
52
# supported platform in simplejson 2.1.0+.
53
self.assertEquals(d2, expect)