diff options
Diffstat (limited to 'test/netlib/test_multidict.py')
-rw-r--r-- | test/netlib/test_multidict.py | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/test/netlib/test_multidict.py b/test/netlib/test_multidict.py index 038441e7..58ae0f98 100644 --- a/test/netlib/test_multidict.py +++ b/test/netlib/test_multidict.py @@ -45,7 +45,7 @@ class TestMultiDict(object): assert md["foo"] == "bar" with tutils.raises(KeyError): - md["bar"] + assert md["bar"] md_multi = TMultiDict( [("foo", "a"), ("foo", "b")] @@ -101,6 +101,15 @@ class TestMultiDict(object): assert TMultiDict() != self._multi() assert TMultiDict() != 42 + def test_hash(self): + """ + If a class defines mutable objects and implements an __eq__() method, + it should not implement __hash__(), since the implementation of hashable + collections requires that a key's hash value is immutable. + """ + with tutils.raises(TypeError): + assert hash(TMultiDict()) + def test_get_all(self): md = self._multi() assert md.get_all("foo") == ["bar"] @@ -197,6 +206,9 @@ class TestImmutableMultiDict(object): with tutils.raises(TypeError): md.add("foo", "bar") + def test_hash(self): + assert hash(TImmutableMultiDict()) + def test_with_delitem(self): md = TImmutableMultiDict([("foo", "bar")]) assert md.with_delitem("foo").fields == () |