示例#1
0
 def test_repr(self) -> None:
     d1 = {'a': 2, 'b': 3}
     d2 = {'a': 1}
     cp = helpers.ChainMapProxy([d1, d2])
     expected = "ChainMapProxy({!r}, {!r})".format(d1, d2)
     assert expected == repr(cp)
示例#2
0
 def test_iter(self) -> None:
     d1 = {'a': 2, 'b': 3}
     d2 = {'a': 1}
     cp = helpers.ChainMapProxy([d1, d2])
     assert set(cp) == {'a', 'b'}
示例#3
0
 def test_bool(self) -> None:
     assert helpers.ChainMapProxy([{'a': 1}])
     assert not helpers.ChainMapProxy([{}, {}])
     assert not helpers.ChainMapProxy([])
示例#4
0
 def test_get_non_default(self) -> None:
     d1 = {'a': 2, 'b': 3}
     d2 = {'a': 1}
     cp = helpers.ChainMapProxy([d1, d2])
     assert cp.get('a', 4) == 2
示例#5
0
 def test_len(self) -> None:
     d1 = {'a': 2, 'b': 3}
     d2 = {'a': 1}
     cp = helpers.ChainMapProxy([d1, d2])
     assert len(cp) == 2
示例#6
0
 def test_getitem(self) -> None:
     d1 = {'a': 2, 'b': 3}
     d2 = {'a': 1}
     cp = helpers.ChainMapProxy([d1, d2])
     assert cp['a'] == 2
     assert cp['b'] == 3
示例#7
0
 def test_getitem_not_found(self) -> None:
     d = {'a': 1}
     cp = helpers.ChainMapProxy([d])
     with pytest.raises(KeyError):
         cp['b']
示例#8
0
 def test_repr(self) -> None:
     d1 = {"a": 2, "b": 3}
     d2 = {"a": 1}
     cp = helpers.ChainMapProxy([d1, d2])
     expected = f"ChainMapProxy({d1!r}, {d2!r})"
     assert expected == repr(cp)
示例#9
0
 def test_iter(self) -> None:
     d1 = {"a": 2, "b": 3}
     d2 = {"a": 1}
     cp = helpers.ChainMapProxy([d1, d2])
     assert set(cp) == {"a", "b"}
示例#10
0
 def test_len(self) -> None:
     d1 = {"a": 2, "b": 3}
     d2 = {"a": 1}
     cp = helpers.ChainMapProxy([d1, d2])
     assert len(cp) == 2
示例#11
0
 def test_get_non_default(self) -> None:
     d1 = {"a": 2, "b": 3}
     d2 = {"a": 1}
     cp = helpers.ChainMapProxy([d1, d2])
     assert cp.get("a", 4) == 2
示例#12
0
 def test_getitem(self) -> None:
     d1 = {"a": 2, "b": 3}
     d2 = {"a": 1}
     cp = helpers.ChainMapProxy([d1, d2])
     assert cp["a"] == 2
     assert cp["b"] == 3