示例#1
0
    def test_toOrigNominal(self):
        j = Json()
        j.a = Json({"b": "c"})
        j.toString()
        j.toOrig()
        repr(j)
        d = j.toOrig()

        self.assertIsInstance(d, sdict)
        self.assertDictEqual(d, {"a": {"b": "c"}})
示例#2
0
    def test_update_with_lists(self):
        org = Json()
        org.a = [1, 2, {"a": "superman"}]
        someother = Json()
        someother.b = [{"b": 123}]
        org.update(someother)

        correct = {"a": [1, 2, {"a": "superman"}], "b": [{"b": 123}]}

        org.update(someother)
        self.assertDictEqual(org, correct)
        self.assertIsInstance(org.b[0], Json)
示例#3
0
 def test_repr_used_setattr(self):
     j = Json()
     j.a = "a"
     self.assertEqual(repr(j), repr({"a": "a"}))
示例#4
0
 def test_complex_nested_structure(self):
     prop = Json()
     prop.a = [[Json(), 2], [[]], [1, [2, 3], 0]]
     self.assertDictEqual(prop, {"a": [[{}, 2], [[]], [1, [2, 3], 0]]})
示例#5
0
 def test_set_one_level_property(self):
     prop = Json()
     prop.a = TEST_VAL
     self.assertDictEqual(prop, {"a": TEST_VAL})