def test_equal(self):
        d1 = {"a": 2, "b": {"c": 3}}
        d2 = {"a": 2, "b": 3}
        d3 = {"a": 2, "c": 8}
        d4 = {"b": {"c": 4}, "a": 2}
        d5 = {"b": {"c": 3}, "a": 2}

        self.assertFalse(dict_equal(d1, d2))
        self.assertFalse(dict_equal(d1, d3))
        self.assertFalse(dict_equal(d1, d4))
        self.assertTrue(dict_equal(d1, d5))
Ejemplo n.º 2
0
    def test_equal(self):
        d1 = {"a": 2, "b": {"c": 3}}
        d2 = {"a": 2, "b": 3}
        d3 = {"a": 2, "c": 8}
        d4 = {"b": {"c": 4}, "a": 2}
        d5 = {"b": {"c": 3}, "a": 2}

        self.assertFalse(dict_equal(d1, d2))
        self.assertFalse(dict_equal(d1, d3))
        self.assertFalse(dict_equal(d1, d4))
        self.assertTrue(dict_equal(d1, d5))
Ejemplo n.º 3
0
    def test_read_key(self):

        self.assertEqual(cfg.read(key="bar.blah").data, "blarg")

        self.assertTrue(dict_equal(cfg.read(key="bar.meh").data,
                                   {"a": 1, "b": 2, "c": 3}))
        self.assertTrue(cfg.read(key="q").data is None)
Ejemplo n.º 4
0
 def test_read_key(self):
     self.assertTrue(cfg.read(key="foo.bar"), "baz")
     self.assertTrue(
         dict_equal(
             cfg.read(key="section").data, {
                 "stuff": "things",
                 "other": "something else blah blah blah"
             }))
Ejemplo n.º 5
0
 def test_read_key(self):
     self.assertTrue(cfg.read(key="foo.bar"), "baz")
     self.assertTrue(
         dict_equal(cfg.read(key="section").data,
                    {
                        "stuff": "things",
                        "other": "something else blah blah blah"
                    }))
Ejemplo n.º 6
0
    def test_read_key(self):

        self.assertEqual(cfg.read(key="bar.blah").data, "blarg")

        self.assertTrue(
            dict_equal(cfg.read(key="bar.meh").data, {
                "a": 1,
                "b": 2,
                "c": 3
            }))
        self.assertTrue(cfg.read(key="q").data is None)
Ejemplo n.º 7
0
    def test_read(self):
        expected = {
            "bar.meh.a": 1,
            "bar.meh.b": 2,
            "bar.meh.c": 3,
            "bar.blah": "blarg",
            "foo": "baz",
            "q": None
        }

        self.assertTrue(dict_equal(cfg.read().data, expected))
Ejemplo n.º 8
0
    def test_read(self):
        expected = {
            "foo.bar": "baz",
            "foo.blah": "2",
            "section.stuff": "things",
            "section.other": "something else blah blah blah"
        }

        blah = cfg.read().data

        self.assertTrue(dict_equal(cfg.read().data, expected))
Ejemplo n.º 9
0
    def test_read(self):
        expected = {
            "foo.bar": "baz",
            "foo.blah": "2",
            "section.stuff": "things",
            "section.other": "something else blah blah blah"
        }

        blah = cfg.read().data

        self.assertTrue(dict_equal(cfg.read().data, expected))
Ejemplo n.º 10
0
    def test_read(self):
        expected = {
            "bar.meh.a": 1,
            "bar.meh.b": 2,
            "bar.meh.c": 3,
            "bar.blah": "blarg",
            "foo": "baz",
            "q": None
        }

        self.assertTrue(dict_equal(cfg.read().data, expected))
Ejemplo n.º 11
0
    def test_json(self):
        expected = {
            "first": {
                "foo": "bar",
                "baz": 3
            },
            "second": {
                "blarg": "something something\nsomething"
            }
        }

        self.assertTrue(self.cfg_json.exists())
        self.assertTrue(
            dict_equal(self.cfg_json.read(flatten=False).data, expected))
Ejemplo n.º 12
0
    def test_read(self):
        expected = {"x": 42, "foo": "bar", "square": lambda x: x**2}

        received = cfg.read().data

        self.assertEqual(set(expected.keys()), set(received.keys()))
        self.assertTrue(
            dict_equal(
                {k: v
                 for k, v in expected.items() if k in ["x", "foo"]},
                {k: v
                 for k, v in received.items() if k in ["x", "foo"]}))

        for i in range(10):
            self.assertEqual(expected["square"](i), received["square"](i))
 def test_unflatten(self):
     self.assertTrue(dict_equal(unflatten_dict(dict_flat), dict_unflat))
Ejemplo n.º 14
0
 def test_unflatten(self):
     self.assertTrue(dict_equal(unflatten_dict(dict_flat), dict_unflat))