summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_bsddb.py
diff options
context:
space:
mode:
authorRoger E. Masse <rmasse@newcnri.cnri.reston.va.us>1997-01-16 22:04:10 (GMT)
committerRoger E. Masse <rmasse@newcnri.cnri.reston.va.us>1997-01-16 22:04:10 (GMT)
commit352e186749631c0697e9b5717a4402376386c05a (patch)
tree37c58c34216b19dfb37f580edf05c3ddf37ee731 /Lib/test/test_bsddb.py
parent7d18159614b07d2a3a4404f8ae8d6f9258e253a1 (diff)
downloadcpython-352e186749631c0697e9b5717a4402376386c05a.zip
cpython-352e186749631c0697e9b5717a4402376386c05a.tar.gz
cpython-352e186749631c0697e9b5717a4402376386c05a.tar.bz2
Test script for the bsddb C extension module.
Diffstat (limited to 'Lib/test/test_bsddb.py')
-rwxr-xr-xLib/test/test_bsddb.py69
1 files changed, 69 insertions, 0 deletions
diff --git a/Lib/test/test_bsddb.py b/Lib/test/test_bsddb.py
new file mode 100755
index 0000000..7a95eb9
--- /dev/null
+++ b/Lib/test/test_bsddb.py
@@ -0,0 +1,69 @@
+#! /usr/bin/env python
+"""Test script for the bsddb C module
+ Roger E. Masse
+"""
+import bsddb
+import tempfile
+from test_support import verbose
+
+def test(openmethod, what):
+
+ if verbose:
+ print '\nTesting: ', what
+
+ fname = tempfile.mktemp()
+ f = openmethod(fname, 'c')
+ if verbose:
+ print 'creation...'
+ f['0'] = ''
+ f['a'] = 'Guido'
+ f['b'] = 'van'
+ f['c'] = 'Rossum'
+ f['d'] = 'invented'
+ f['f'] = 'Python'
+ if verbose:
+ print '%s %s %s' % (f['a'], f['b'], f['c'])
+
+ if what == 'BTree' :
+ if verbose:
+ print 'key ordering...'
+ f.set_location(f.first()[0])
+ while 1:
+ try:
+ rec = f.next()
+ except KeyError:
+ if rec <> f.last():
+ print 'Error, last <> last!'
+ f.previous()
+ break
+ if verbose:
+ print rec
+ if not f.has_key('a'):
+ print 'Error, missing key!'
+
+ f.sync()
+ f.close()
+ 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
+
+ f.close()
+
+types = [(bsddb.btopen, 'BTree'),
+ (bsddb.hashopen, 'Hash Table'),
+ # (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])
+