]>
git.proxmox.com Git - mirror_edk2.git/blob - AppPkg/Applications/Python/Python-2.7.10/Lib/json/tests/test_indent.py
2 from StringIO
import StringIO
3 from json
.tests
import PyTest
, CTest
6 class TestIndent(object):
8 h
= [['blorpie'], ['whoops'], [], 'd-shtaeou', 'd-nthiouh', 'i-vhbjkhnth',
9 {'nifty': 87}, {'field': 'yes', 'morefield': False} ]
11 expect
= textwrap
.dedent("""\
34 d2
= self
.dumps(h
, indent
=2, sort_keys
=True, separators
=(',', ': '))
39 self
.assertEqual(h1
, h
)
40 self
.assertEqual(h2
, h
)
41 self
.assertEqual(d2
, expect
)
43 def test_indent0(self
):
45 def check(indent
, expected
):
46 d1
= self
.dumps(h
, indent
=indent
)
47 self
.assertEqual(d1
, expected
)
50 self
.json
.dump(h
, sio
, indent
=indent
)
51 self
.assertEqual(sio
.getvalue(), expected
)
53 # indent=0 should emit newlines
54 check(0, '{\n"3": 1\n}')
55 # indent=None is more compact
56 check(None, '{"3": 1}')
59 class TestPyIndent(TestIndent
, PyTest
): pass
60 class TestCIndent(TestIndent
, CTest
): pass