Exemplo n.º 1
0
    def test_basic(self):

        p = idict()
        self.assertEqual(p.local, {})
        self.assertEqual(p.inherited, {})

        # update the (local) values
        p.update(x=1, y=2, z=3)
        self.assertEqual(p, p.local)
        self.assertNotEqual(p, p.inherited)
        self.assertEqual(len(p), 3)
        self.assertEqual(len(p.local), 3)
        self.assertEqual(len(p.inherited), 0)

        # update inherited values
        p.inherited.update(a=1, b=2, c=3)
        self.assertNotEqual(p, p.local)
        self.assertNotEqual(p, p.inherited)
        self.assertEqual(len(p), 6)
        self.assertEqual(len(p.local), 3)
        self.assertEqual(len(p.inherited), 3)

        # perform some updates in place
        p["a"] = 100
        self.assertEqual(p.get("a"), 100)
        self.assertEqual(p.local.get("a"), 100)

        # local now has an override
        self.assertEqual(len(p), 6)
        self.assertEqual(len(p.local), 4)
        self.assertEqual(len(p.inherited), 3)
Exemplo n.º 2
0
    def test_basic(self):

        p = idict()
        self.assertEqual(p.local, {})
        self.assertEqual(p.inherited, {})
        
        # update the (local) values
        p.update(x=1, y=2, z=3)
        self.assertEqual(p, p.local)
        self.assertNotEqual(p, p.inherited)
        self.assertEqual(len(p), 3)
        self.assertEqual(len(p.local), 3)
        self.assertEqual(len(p.inherited), 0)

        # update inherited values
        p.inherited.update(a=1, b=2, c=3)
        self.assertNotEqual(p, p.local)
        self.assertNotEqual(p, p.inherited)
        self.assertEqual(len(p), 6)
        self.assertEqual(len(p.local), 3)
        self.assertEqual(len(p.inherited), 3)
        
        # perform some updates in place
        p["a"] = 100
        self.assertEqual(p.get("a"), 100)
        self.assertEqual(p.local.get("a"), 100)

        # local now has an override
        self.assertEqual(len(p), 6)
        self.assertEqual(len(p.local), 4)
        self.assertEqual(len(p.inherited), 3)
Exemplo n.º 3
0
    def test_init_kwargs(self):
        p = idict(a=1, b=2, c=3)

        self.assertEqual(len(p), 3)
        self.assertEqual(len(p.local), 3)
        self.assertEqual(len(p.inherited), 0)

        self.assertEqual(p.get("a"), 1)
        self.assertEqual(p.get("b"), 2)
        self.assertEqual(p.get("c"), 3)
Exemplo n.º 4
0
    def test_init_kwargs(self):
        p = idict(a=1, b=2, c=3)

        self.assertEqual(len(p), 3)
        self.assertEqual(len(p.local), 3)
        self.assertEqual(len(p.inherited), 0)

        self.assertEqual(p.get("a"), 1)
        self.assertEqual(p.get("b"), 2)
        self.assertEqual(p.get("c"), 3)
Exemplo n.º 5
0
    def test_init_args(self):
        p = idict({"a": 1, "b": 2})
        self.assertEqual(len(p), 2)
        self.assertEqual(len(p.local), 2)
        self.assertEqual(len(p.inherited), 0)

        p.inherited.update(a=2, b=3, c=4)
        self.assertEqual(len(p), 3)
        self.assertEqual(len(p.local), 2)
        self.assertEqual(len(p.inherited), 3)

        self.assertEqual(p.get("a"), 1)
        self.assertEqual(p.get("b"), 2)
        self.assertEqual(p.get("c"), 4)
Exemplo n.º 6
0
    def test_init_args(self):
        p = idict({"a": 1, "b":2})
        self.assertEqual(len(p), 2)
        self.assertEqual(len(p.local), 2)
        self.assertEqual(len(p.inherited), 0)

        p.inherited.update(a=2, b=3, c=4)
        self.assertEqual(len(p), 3)
        self.assertEqual(len(p.local), 2)
        self.assertEqual(len(p.inherited), 3)

        self.assertEqual(p.get("a"), 1)
        self.assertEqual(p.get("b"), 2)
        self.assertEqual(p.get("c"), 4)