Ejemplo n.º 1
0
    def test_items_iteration_gives_yaml(self):
        d = YamlDict(content={
            "a": {
                "x": 1
            },
        })

        for k, v in d._items():
            self.assertEqual("a", k)
            self.assertTrue(
                isinstance(v, YamlDict),
                "The iterated property over items is not an YamlDict",
            )
            self.assertEqual("YamlDict(.a) {'x': 1}", f"{v}")
            self.assertEqual(1, d.a.x)
            self.assertFalse(d.a.y)
Ejemplo n.º 2
0
    def test_iteration_key_value(self):
        p = YamlDict(content={
            "x": "x",
            "y": "y",
            "z": "z",
        })

        items = dict()

        for k, v in p._items():
            items[k] = v

        self.assertDictEqual(
            {
                "x": "x",
                "y": "y",
                "z": "z",
            },
            items,
        )