mirror of
https://github.com/python/cpython.git
synced 2024-12-14 20:34:12 +08:00
be19ed77dd
There's one major and one minor category still unfixed: doctests are the major category (and I hope to be able to augment the refactoring tool to refactor bona fide doctests soon); other code generating print statements in strings is the minor category. (Oh, and I don't know if the compiler package works.)
47 lines
850 B
Python
Executable File
47 lines
850 B
Python
Executable File
#! /usr/bin/env python
|
|
"""Test script for the gdbm module
|
|
Roger E. Masse
|
|
"""
|
|
|
|
import gdbm
|
|
from gdbm import error
|
|
from test.test_support import verbose, verify, TestFailed, TESTFN
|
|
|
|
filename = TESTFN
|
|
|
|
g = gdbm.open(filename, 'c')
|
|
verify(g.keys() == [])
|
|
g['a'] = 'b'
|
|
g['12345678910'] = '019237410982340912840198242'
|
|
a = g.keys()
|
|
if verbose:
|
|
print('Test gdbm file keys: ', a)
|
|
|
|
'a' in g
|
|
g.close()
|
|
try:
|
|
g['a']
|
|
except error:
|
|
pass
|
|
else:
|
|
raise TestFailed, "expected gdbm.error accessing closed database"
|
|
g = gdbm.open(filename, 'r')
|
|
g.close()
|
|
g = gdbm.open(filename, 'w')
|
|
g.close()
|
|
g = gdbm.open(filename, 'n')
|
|
g.close()
|
|
try:
|
|
g = gdbm.open(filename, 'rx')
|
|
g.close()
|
|
except error:
|
|
pass
|
|
else:
|
|
raise TestFailed, "expected gdbm.error when passing invalid open flags"
|
|
|
|
try:
|
|
import os
|
|
os.unlink(filename)
|
|
except:
|
|
pass
|