diff options
author | Raymond Hettinger <python@rcn.com> | 2003-09-12 06:33:37 (GMT) |
---|---|---|
committer | Raymond Hettinger <python@rcn.com> | 2003-09-12 06:33:37 (GMT) |
commit | deadbf50e4cc3c541e706d5bf1aa73624bed36a6 (patch) | |
tree | 407b9e5f2aa93866cdda5fb5b70fee3d49d2de0e /Lib/test/test_bsddb.py | |
parent | 74c8e55f3b64b8819a1950be4ac1323c74931cc2 (diff) | |
download | cpython-deadbf50e4cc3c541e706d5bf1aa73624bed36a6.zip cpython-deadbf50e4cc3c541e706d5bf1aa73624bed36a6.tar.gz cpython-deadbf50e4cc3c541e706d5bf1aa73624bed36a6.tar.bz2 |
SF #662923
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.
Diffstat (limited to 'Lib/test/test_bsddb.py')
-rwxr-xr-x | Lib/test/test_bsddb.py | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/Lib/test/test_bsddb.py b/Lib/test/test_bsddb.py index aa58ef8..87145fb 100755 --- a/Lib/test/test_bsddb.py +++ b/Lib/test/test_bsddb.py @@ -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']) |