예제 #1
0
    def test_ancestor_delitem(self):
        cd = ChainedDict(**{"the_key": True})
        cd2 = ChainedDict(parent=cd, **{"the_other_key": True})

        del cd["the_key"]

        assert "the_key" not in cd2
예제 #2
0
    def test_iter_with_ancestor_with_deletion(self):
        cd = ChainedDict(**{"the_key": True})
        cd2 = ChainedDict(parent=cd, **{"the_other_key": True})

        del cd2["the_key"]

        set(key for key in cd2) == set(["the_other_key"])
예제 #3
0
    def test_contains_ancestral(self):
        cd = ChainedDict(**{"the_key": True})
        cd2 = ChainedDict(parent=cd, **{"the_other_key": True})

        assert "the_key" in  cd2
        assert "the_other_key" in cd2
        assert "the_other_key" not in cd
예제 #4
0
    def test_delitem_with_ancestor(self):
        cd = ChainedDict(**{"the_key": True})
        cd2 = ChainedDict(parent=cd)

        del cd2["the_key"]

        assert "the_key" not in cd2
        assert "the_key" in cd
예제 #5
0
    def test_setitem_direct_not_affect_ancestral(self):
        cd = ChainedDict(**{"the_key": True})
        cd2 = ChainedDict(parent=cd)

        cd2["the_key"] = False

        assert cd2["the_key"] == False
        assert cd["the_key"] == True
예제 #6
0
    def test_iter_with_ancestor(self):
        cd = ChainedDict(**{"the_key": True})
        cd2 = ChainedDict(parent=cd, **{"the_other_key": True})

        assert set(key for key in cd2) == set(["the_key", "the_other_key"])
        assert set(key for key in cd) == set(["the_key"])
예제 #7
0
    def test_iter(self):
        cd = ChainedDict(**{"the_key": True})

        set(key for key in cd) == set(["the_key"])
예제 #8
0
 def test_bare_initialization(self):
     ChainedDict()
예제 #9
0
    def test_len_with_ancestor(self):
        cd = ChainedDict(**{"the_key": True})
        cd2 = ChainedDict(parent=cd, **{"the_other_key": True})

        assert len(cd2) == 2
예제 #10
0
    def test_len(self):
        cd = ChainedDict(**{"the_key": True})

        assert len(cd) == 1
예제 #11
0
    def test_delitem_invalid_key(self):
        cd = ChainedDict()

        with pytest.raises(KeyError):
            del cd["anything"]
예제 #12
0
    def test_delitem(self):
        cd = ChainedDict({"the_key": True})
        del cd["the_key"]

        assert "the_key" not in cd
예제 #13
0
    def test_contains_direct(self):
        cd = ChainedDict()
        cd["the_key"] = True

        assert "the_key" in cd
        assert "not_the_key" not in cd