1996-12-17 20:54:27 +01:00
|
|
|
#! /usr/bin/env python
|
|
|
|
"""Test script for the gdbm module
|
|
|
|
Roger E. Masse
|
|
|
|
"""
|
|
|
|
|
|
|
|
import gdbm
|
|
|
|
from gdbm import error
|
2000-02-07 18:15:48 +01:00
|
|
|
from test_support import verbose, TestFailed
|
1996-12-20 23:36:52 +01:00
|
|
|
|
1996-12-17 20:54:27 +01:00
|
|
|
filename= '/tmp/delete_me'
|
|
|
|
|
|
|
|
g = gdbm.open(filename, 'c')
|
|
|
|
g['a'] = 'b'
|
|
|
|
g['12345678910'] = '019237410982340912840198242'
|
|
|
|
a = g.keys()
|
|
|
|
if verbose:
|
|
|
|
print 'Test gdbm file keys: ', a
|
|
|
|
|
|
|
|
g.has_key('a')
|
|
|
|
g.close()
|
2000-02-07 18:15:48 +01:00
|
|
|
try:
|
|
|
|
g['a']
|
|
|
|
except error:
|
|
|
|
pass
|
|
|
|
else:
|
|
|
|
raise TestFailed, "expected gdbm.error accessing closed database"
|
1996-12-17 20:54:27 +01:00
|
|
|
g = gdbm.open(filename, 'r')
|
|
|
|
g.close()
|
|
|
|
g = gdbm.open(filename, 'rw')
|
|
|
|
g.close()
|
|
|
|
g = gdbm.open(filename, 'w')
|
|
|
|
g.close()
|
|
|
|
g = gdbm.open(filename, 'n')
|
|
|
|
g.close()
|
|
|
|
|
|
|
|
try:
|
|
|
|
import os
|
|
|
|
os.unlink(filename)
|
|
|
|
except:
|
|
|
|
pass
|