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"}})
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)
def test_repr_used_setattr(self): j = Json() j.a = "a" self.assertEqual(repr(j), repr({"a": "a"}))
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]]})
def test_set_one_level_property(self): prop = Json() prop.a = TEST_VAL self.assertDictEqual(prop, {"a": TEST_VAL})