summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_bsddb.py
diff options
context:
space:
mode:
authorAnthony Baxter <anthonybaxter@gmail.com>2002-04-23 02:11:05 (GMT)
committerAnthony Baxter <anthonybaxter@gmail.com>2002-04-23 02:11:05 (GMT)
commit8388895fe43da057006e50cae5d1b6e2a12083e0 (patch)
tree4b4315181abceff4b1f0c1e32975ed88a7330665 /Lib/test/test_bsddb.py
parent0494955b8f88007df3038c0e3de92ac8b4558f77 (diff)
downloadcpython-8388895fe43da057006e50cae5d1b6e2a12083e0.zip
cpython-8388895fe43da057006e50cae5d1b6e2a12083e0.tar.gz
cpython-8388895fe43da057006e50cae5d1b6e2a12083e0.tar.bz2
SF patch [ 545523 ] patch for 514433 bsddb.dbopen (NULL)
closes SF #514433 can now pass 'None' as the filename for the bsddb.*open functions, and you'll get an in-memory temporary store. docs are ripped out of the bsddb dbopen man page. Fred may want to clean them up. Considering this for 2.2, but not 2.1.
Diffstat (limited to 'Lib/test/test_bsddb.py')
-rwxr-xr-xLib/test/test_bsddb.py45
1 files changed, 26 insertions, 19 deletions
diff --git a/Lib/test/test_bsddb.py b/Lib/test/test_bsddb.py
index 459dd5f..f68acae 100755
--- a/Lib/test/test_bsddb.py
+++ b/Lib/test/test_bsddb.py
@@ -2,19 +2,21 @@
"""Test script for the bsddb C module
Roger E. Masse
"""
-
import os
import bsddb
import dbhash # Just so we know it's imported
import tempfile
from test_support import verbose, verify
-def test(openmethod, what):
+def test(openmethod, what, ondisk=1):
if verbose:
- print '\nTesting: ', what
+ print '\nTesting: ', what, (ondisk and "on disk" or "in memory")
- fname = tempfile.mktemp()
+ if ondisk:
+ fname = tempfile.mktemp()
+ else:
+ fname = None
f = openmethod(fname, 'c')
verify(f.keys() == [])
if verbose:
@@ -47,30 +49,35 @@ def test(openmethod, what):
f.sync()
f.close()
- if verbose:
- print 'modification...'
- f = openmethod(fname, 'w')
- f['d'] = 'discovered'
+ if ondisk:
+ # if we're using an in-memory only db, we can't reopen it
+ # so finish here.
+ if verbose:
+ print 'modification...'
+ f = openmethod(fname, 'w')
+ f['d'] = 'discovered'
- if verbose:
- print 'access...'
- for key in f.keys():
- word = f[key]
if verbose:
- print word
+ print 'access...'
+ for key in f.keys():
+ word = f[key]
+ if verbose:
+ print word
- f.close()
- try:
- os.remove(fname)
- except os.error:
- pass
+ f.close()
+ try:
+ os.remove(fname)
+ except os.error:
+ pass
types = [(bsddb.btopen, 'BTree'),
(bsddb.hashopen, 'Hash Table'),
+ (bsddb.btopen, 'BTree', 0),
+ (bsddb.hashopen, 'Hash Table', 0),
# (bsddb.rnopen,'Record Numbers'), 'put' for RECNO for bsddb 1.85
# appears broken... at least on
# Solaris Intel - rmasse 1/97
]
for type in types:
- test(type[0], type[1])
+ test(*type)