multidict: remove to_dict

We never use it, and it is dangerously ambiguous when a key is associated with
a list.
This commit is contained in:
Aldo Cortesi 2016-10-21 11:41:54 +13:00
parent 18ee6255c0
commit cc8b422d9d
2 changed files with 0 additions and 28 deletions

View File

@ -174,27 +174,6 @@ class _MultiDict(MutableMapping, serializable.Serializable, metaclass=ABCMeta):
coll.append([key, values])
return coll
def to_dict(self):
"""
Get the MultiDict as a plain Python dict.
Keys with multiple values are returned as lists.
Example:
.. code-block:: python
# Simple dict with duplicate values.
>>> d = MultiDict([("name", "value"), ("a", False), ("a", 42)])
>>> d.to_dict()
{
"name": "value",
"a": [False, 42]
}
"""
return {
k: v for k, v in self.collect()
}
def get_state(self):
return self.fields

View File

@ -172,13 +172,6 @@ class TestMultiDict:
assert list(md.items()) == [("foo", "bar"), ("bar", "baz")]
assert list(md.items(multi=True)) == [("foo", "bar"), ("bar", "baz"), ("Bar", "bam")]
def test_to_dict(self):
md = self._multi()
assert md.to_dict() == {
"foo": "bar",
"bar": ["baz", "bam"]
}
def test_state(self):
md = self._multi()
assert len(md.get_state()) == 3