add MultiDictView.copy

This commit is contained in:
Maximilian Hils 2017-03-14 02:18:02 +01:00
parent 124a6c9e5a
commit de1de3f626
2 changed files with 12 additions and 0 deletions

View File

@ -230,3 +230,6 @@ class MultiDictView(_MultiDict):
@fields.setter
def fields(self, value):
self._setter(value)
def copy(self):
return MultiDict(self.fields)

View File

@ -205,3 +205,12 @@ class TestMultiDictView:
tv["c"] = "b"
assert p.vals == (("a", "b"), ("c", "b"))
assert tv["a"] == "b"
def test_copy(self):
p = TParent()
tv = multidict.MultiDictView(p.getter, p.setter)
c = tv.copy()
assert isinstance(c, multidict.MultiDict)
assert tv.items() == c.items()
c["foo"] = "bar"
assert tv.items() != c.items()