예제 #1
0
    def test_write_with_property(self):
        p = YamlDict(content={"x": "original"})

        p.x = "new"

        self.assertEqual("new", p.x)
        self.assertEqual("new", p["x"])
예제 #2
0
    def test_set_nested_property_navigator(self):
        """
        The `__content` should always be kept as objects pointing to each other,
        not property navigators.
        :return:
        """
        p = YamlDict()
        x = YamlDict()

        p.x = x
        p.x.y1 = "y1"
        x.y2 = "y2"
        p.y = "y"

        self.assertEqual({"x": {"y1": "y1", "y2": "y2"}, "y": "y"}, p._raw)