Issue #7673: Fix security vulnerability (CVE-2010-2089) in the audioop module,
[python/dscho.git] / Lib / json / tests / test_separators.py
blob32db3419296cbfeda410430df754164a0a9d4f3f
1 import textwrap
2 from unittest import TestCase
4 import json
7 class TestSeparators(TestCase):
8 def test_separators(self):
9 h = [['blorpie'], ['whoops'], [], 'd-shtaeou', 'd-nthiouh', 'i-vhbjkhnth',
10 {'nifty': 87}, {'field': 'yes', 'morefield': False} ]
12 expect = textwrap.dedent("""\
15 "blorpie"
16 ] ,
18 "whoops"
19 ] ,
20 [] ,
21 "d-shtaeou" ,
22 "d-nthiouh" ,
23 "i-vhbjkhnth" ,
25 "nifty" : 87
26 } ,
28 "field" : "yes" ,
29 "morefield" : false
31 ]""")
34 d1 = json.dumps(h)
35 d2 = json.dumps(h, indent=2, sort_keys=True, separators=(' ,', ' : '))
37 h1 = json.loads(d1)
38 h2 = json.loads(d2)
40 self.assertEquals(h1, h)
41 self.assertEquals(h2, h)
42 self.assertEquals(d2, expect)