~ubuntu-branches/ubuntu/lucid/exaile/lucid

« back to all changes in this revision

Viewing changes to plugins/jamendo/simplejson/tests/test_indent.py

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Starr-Bochicchio
  • Date: 2010-02-12 19:51:01 UTC
  • mfrom: (1.1.11 upstream)
  • Revision ID: james.westby@ubuntu.com-20100212195101-8jt3tculxcl92e6v
Tags: 0.3.1~b1-0ubuntu1
* New upstream release.
* Adjust exaile.install for new plugins.
* debian/control:
 - Drop unneeded python-dev Build-Dep.
 - Bump Standards-Version to 3.8.4 
* debian/rules: No empty po files to delete.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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)