Convert test_userdict to use the collections.UserDict.

Fix-up collections.UserDict.__contains__ to work correctly when __missing__ is defined.
Fix-up Mapping.__eq__ to only match instances of Mapping.
This commit is contained in:
Raymond Hettinger 2008-02-05 22:54:43 +00:00
parent f01fe6915b
commit 554c8b856c
3 changed files with 39 additions and 41 deletions

View file

@ -135,6 +135,9 @@ class UserDict(MutableMapping):
def __iter__(self):
return iter(self.data)
# Modify __contains__ to work correctly when __missing__ is present
def __contains__(self, key):
return key in self.data
# Now, add the methods in dicts but not in MutableMapping
def __repr__(self): return repr(self.data)