Add support for the iterator and mapping protocols.
For Py2.3, this was done for shelve, dumbdbm and other mapping objects, but
not for bsddb and dbhash which were inadvertently missed.
This commit is contained in:
Raymond Hettinger 2003-09-12 06:33:37 +00:00
parent 74c8e55f3b
commit deadbf50e4
5 changed files with 56 additions and 16 deletions

View file

@ -20,12 +20,24 @@ def test(openmethod, what, ondisk=1):
verify(f.keys() == [])
if verbose:
print 'creation...'
f['0'] = ''
f['a'] = 'Guido'
f['b'] = 'van'
f['c'] = 'Rossum'
f['d'] = 'invented'
f['f'] = 'Python'
keys = ['0', 'a', 'b', 'c', 'd', 'e', 'f']
values = ['', 'Guido', 'van', 'Rossum', 'invented', 'Python']
items = zip(keys, values)
for k, v in items:
f[k] = v
# test mapping iteration methods
from sets import Set
def verifyset(s1, s2):
verify(Set(s1) == Set(s2))
verify(keys, f.keys())
verify(values, f.values())
verify(items, f.items())
verify(keys, f)
verify(keys, f.iterkeys())
verify(values, f.itervalues())
verify(items, f.iteritems())
if verbose:
print '%s %s %s' % (f['a'], f['b'], f['c'])