Add tests for the collections helper class and sync-up with py3k branch.

This commit is contained in:
Raymond Hettinger 2011-02-23 08:28:06 +00:00
parent 48e5cd3df3
commit dcb29c93d2
2 changed files with 121 additions and 2 deletions

View file

@ -694,6 +694,15 @@ class _ChainMap(MutableMapping):
__copy__ = copy
def new_child(self): # like Django's Context.push()
'New ChainMap with a new dict followed by all previous maps.'
return self.__class__({}, *self.maps)
@property
def parents(self): # like Django's Context.pop()
'New ChainMap from maps[1:].'
return self.__class__(*self.maps[1:])
def __setitem__(self, key, value):
self.maps[0][key] = value