Example #1
0
    def test_dump_dict(self):
        data = dumps({'a': {'d': 1}})
        loads(data)
        self.assertEquals(data, """\
a {
  d = 1
}
""")
Example #2
0
    def test_dump_dict(self):
        data = dumps({'a': {'d': 1}})
        loads(data)
        self.assertEquals(data, """\
a {
  d = 1
}
""")
Example #3
0
    def test_dump_list(self):
        data = dumps({'a': ['a', 'b', 'c']})
        self.assertEquals(data, """\
a = {
  a
  b
  c
}
""")
Example #4
0
    def test_dump_list(self):
        data = dumps({'a': ['a', 'b', 'c']})
        self.assertEquals(data, """\
a = {
  a
  b
  c
}
""")
Example #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())
Example #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())
Example #7
0
    def test_dump_false_bool(self):
        data = dumps({'a': False})
        loads(data)
        self.assertEquals(data, """\
a = false
""")
Example #8
0
    def test_dump_true_bool(self):
        data = dumps({'a': True})
        loads(data)
        self.assertEquals(data, """\
a = true
""")
Example #9
0
    def test_escape_space(self):
        data = dumps({'a b': 1})
        loads(data)
        self.assertEquals(data, """\
"a b" = 1
""")
Example #10
0
    def test_dump_false_bool(self):
        data = dumps({'a': False})
        loads(data)
        self.assertEquals(data, """\
a = false
""")
Example #11
0
    def test_dump_true_bool(self):
        data = dumps({'a': True})
        loads(data)
        self.assertEquals(data, """\
a = true
""")
Example #12
0
    def test_escape_space(self):
        data = dumps({'a b': 1})
        loads(data)
        self.assertEquals(data, """\
"a b" = 1
""")