Beispiel #1
0
    def test_dump_dict(self):
        data = dumps({'a': {'d': 1}})
        loads(data)
        self.assertEquals(data, """\
a {
  d = 1
}
""")
Beispiel #2
0
    def test_dump_dict(self):
        data = dumps({'a': {'d': 1}})
        loads(data)
        self.assertEquals(data, """\
a {
  d = 1
}
""")
Beispiel #3
0
    def test_dump_list(self):
        data = dumps({'a': ['a', 'b', 'c']})
        self.assertEquals(data, """\
a = {
  a
  b
  c
}
""")
Beispiel #4
0
    def test_dump_list(self):
        data = dumps({'a': ['a', 'b', 'c']})
        self.assertEquals(data, """\
a = {
  a
  b
  c
}
""")
Beispiel #5
0
    def test_object_order_is_kept(self):
        """Verify that the items in objects are kept in order."""
        order = random.sample(range(100), 100)
        string = "\n".join("property%d = %d" % (i, i) for i in order)

        result = loads(string)
        for (key, value), i in zip(result.items(), order):
            self.assertEquals(value, i)

        new_string = dumps(result)
        self.assertEquals(string, str(new_string).rstrip())
Beispiel #6
0
    def test_object_order_is_kept(self):
        """Verify that the items in objects are kept in order."""
        order = random.sample(range(100), 100)
        string = "\n".join("property%d = %d" % (i, i) for i in order)

        result = loads(string)
        for (key, value), i in zip(result.items(), order):
            self.assertEquals(value, i)

        new_string = dumps(result)
        self.assertEquals(string, str(new_string).rstrip())
Beispiel #7
0
    def test_dump_false_bool(self):
        data = dumps({'a': False})
        loads(data)
        self.assertEquals(data, """\
a = false
""")
Beispiel #8
0
    def test_dump_true_bool(self):
        data = dumps({'a': True})
        loads(data)
        self.assertEquals(data, """\
a = true
""")
Beispiel #9
0
    def test_escape_space(self):
        data = dumps({'a b': 1})
        loads(data)
        self.assertEquals(data, """\
"a b" = 1
""")
Beispiel #10
0
    def test_dump_false_bool(self):
        data = dumps({'a': False})
        loads(data)
        self.assertEquals(data, """\
a = false
""")
Beispiel #11
0
    def test_dump_true_bool(self):
        data = dumps({'a': True})
        loads(data)
        self.assertEquals(data, """\
a = true
""")
Beispiel #12
0
    def test_escape_space(self):
        data = dumps({'a b': 1})
        loads(data)
        self.assertEquals(data, """\
"a b" = 1
""")