0001 #! /usr/bin/env python 0002 """Test script for the gdbm module 0003 Roger E. Masse 0004 """ 0005 0006 import gdbm 0007 from gdbm import error 0008 from test.test_support import verbose, verify, TestFailed 0009 0010 filename= '/tmp/delete_me' 0011 0012 g = gdbm.open(filename, 'c') 0013 verify(g.keys() == []) 0014 g['a'] = 'b' 0015 g['12345678910'] = '019237410982340912840198242' 0016 a = g.keys() 0017 if verbose: 0018 print 'Test gdbm file keys: ', a 0019 0020 g.has_key('a') 0021 g.close() 0022 try: 0023 g['a'] 0024 except error: 0025 pass 0026 else: 0027 raise TestFailed, "expected gdbm.error accessing closed database" 0028 g = gdbm.open(filename, 'r') 0029 g.close() 0030 g = gdbm.open(filename, 'w') 0031 g.close() 0032 g = gdbm.open(filename, 'n') 0033 g.close() 0034 try: 0035 g = gdbm.open(filename, 'rx') 0036 g.close() 0037 except error: 0038 pass 0039 else: 0040 raise TestFailed, "expected gdbm.error when passing invalid open flags" 0041 0042 try: 0043 import os 0044 os.unlink(filename) 0045 except: 0046 pass 0047
Generated by PyXR 0.9.4