Kaydet (Commit) f6e47ad4 authored tarafından Guido van Rossum's avatar Guido van Rossum

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

like the one I just fixed to come back and haunt us.
üst 4edbc2a5
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
import os import os
import bsddb import bsddb
import tempfile import tempfile
from test_support import verbose from test_support import verbose, verify
def test(openmethod, what): def test(openmethod, what):
...@@ -15,6 +15,7 @@ def test(openmethod, what): ...@@ -15,6 +15,7 @@ def test(openmethod, what):
fname = tempfile.mktemp() fname = tempfile.mktemp()
f = openmethod(fname, 'c') f = openmethod(fname, 'c')
verify(f.keys() == [])
if verbose: if verbose:
print 'creation...' print 'creation...'
f['0'] = '' f['0'] = ''
......
...@@ -4,11 +4,12 @@ ...@@ -4,11 +4,12 @@
""" """
import dbm import dbm
from dbm import error from dbm import error
from test_support import verbose from test_support import verbose, verify
filename = '/tmp/delete_me' filename = '/tmp/delete_me'
d = dbm.open(filename, 'c') d = dbm.open(filename, 'c')
verify(d.keys() == [])
d['a'] = 'b' d['a'] = 'b'
d['12345678910'] = '019237410982340912840198242' d['12345678910'] = '019237410982340912840198242'
d.keys() d.keys()
......
...@@ -5,11 +5,12 @@ ...@@ -5,11 +5,12 @@
import gdbm import gdbm
from gdbm import error from gdbm import error
from test_support import verbose, TestFailed from test_support import verbose, verify, TestFailed
filename= '/tmp/delete_me' filename= '/tmp/delete_me'
g = gdbm.open(filename, 'c') g = gdbm.open(filename, 'c')
verify(g.keys() == [])
g['a'] = 'b' g['a'] = 'b'
g['12345678910'] = '019237410982340912840198242' g['12345678910'] = '019237410982340912840198242'
a = g.keys() a = g.keys()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment