Check that f.keys() == [] right after creation -- this prevents bugs

like the one I just fixed to come back and haunt us.
This commit is contained in:
Guido van Rossum 2001-03-22 00:40:23 +00:00
parent 4edbc2a54f
commit f6e47ad4bd
3 changed files with 6 additions and 3 deletions

View File

@ -6,7 +6,7 @@
import os
import bsddb
import tempfile
from test_support import verbose
from test_support import verbose, verify
def test(openmethod, what):
@ -15,6 +15,7 @@ def test(openmethod, what):
fname = tempfile.mktemp()
f = openmethod(fname, 'c')
verify(f.keys() == [])
if verbose:
print 'creation...'
f['0'] = ''

View File

@ -4,11 +4,12 @@
"""
import dbm
from dbm import error
from test_support import verbose
from test_support import verbose, verify
filename = '/tmp/delete_me'
d = dbm.open(filename, 'c')
verify(d.keys() == [])
d['a'] = 'b'
d['12345678910'] = '019237410982340912840198242'
d.keys()

View File

@ -5,11 +5,12 @@
import gdbm
from gdbm import error
from test_support import verbose, TestFailed
from test_support import verbose, verify, TestFailed
filename= '/tmp/delete_me'
g = gdbm.open(filename, 'c')
verify(g.keys() == [])
g['a'] = 'b'
g['12345678910'] = '019237410982340912840198242'
a = g.keys()