Python 2.1's string module doesn't have ascii_letters, so let's just

hard code it.  We want this module to work with Python 2.1 for now.
This commit is contained in:
Barry Warsaw 2003-01-10 19:28:15 +00:00
parent a21bdeae51
commit 9149aeb842
1 changed files with 10 additions and 13 deletions

View File

@ -1,18 +1,19 @@
""" """TestCases for exercising a Recno DB.
TestCases for exercising a Recno DB.
""" """
import os import os
import sys import sys
import string import errno
import tempfile import tempfile
from pprint import pprint from pprint import pprint
import unittest import unittest
from bsddb import db from bsddb import db
from test_all import verbose from test_all import verbose
letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
#---------------------------------------------------------------------- #----------------------------------------------------------------------
class SimpleRecnoTestCase(unittest.TestCase): class SimpleRecnoTestCase(unittest.TestCase):
@ -22,16 +23,14 @@ class SimpleRecnoTestCase(unittest.TestCase):
def tearDown(self): def tearDown(self):
try: try:
os.remove(self.filename) os.remove(self.filename)
except os.error: except OSError, e:
pass if e.errno <> errno.EEXIST: raise
def test01_basic(self): def test01_basic(self):
d = db.DB() d = db.DB()
d.open(self.filename, db.DB_RECNO, db.DB_CREATE) d.open(self.filename, db.DB_RECNO, db.DB_CREATE)
for x in string.ascii_letters: for x in letters:
recno = d.append(x * 60) recno = d.append(x * 60)
assert type(recno) == type(0) assert type(recno) == type(0)
assert recno >= 1 assert recno >= 1
@ -77,7 +76,6 @@ class SimpleRecnoTestCase(unittest.TestCase):
assert type(keys[0]) == type(123) assert type(keys[0]) == type(123)
assert len(keys) == len(d) assert len(keys) == len(d)
items = d.items() items = d.items()
if verbose: if verbose:
pprint(items) pprint(items)
@ -164,7 +162,6 @@ class SimpleRecnoTestCase(unittest.TestCase):
c.close() c.close()
d.close() d.close()
def test02_WithSource(self): def test02_WithSource(self):
""" """
A Recno file that is given a "backing source file" is essentially a A Recno file that is given a "backing source file" is essentially a
@ -220,7 +217,6 @@ class SimpleRecnoTestCase(unittest.TestCase):
assert text.split('\n') == \ assert text.split('\n') == \
"The quick reddish-brown fox jumped over the comatose dog".split() "The quick reddish-brown fox jumped over the comatose dog".split()
def test03_FixedLength(self): def test03_FixedLength(self):
d = db.DB() d = db.DB()
d.set_re_len(40) # fixed length records, 40 bytes long d.set_re_len(40) # fixed length records, 40 bytes long
@ -228,7 +224,7 @@ class SimpleRecnoTestCase(unittest.TestCase):
d.set_re_pad(45) # ...test both int and char d.set_re_pad(45) # ...test both int and char
d.open(self.filename, db.DB_RECNO, db.DB_CREATE) d.open(self.filename, db.DB_RECNO, db.DB_CREATE)
for x in string.ascii_letters: for x in letters:
d.append(x * 35) # These will be padded d.append(x * 35) # These will be padded
d.append('.' * 40) # this one will be exact d.append('.' * 40) # this one will be exact
@ -251,6 +247,7 @@ class SimpleRecnoTestCase(unittest.TestCase):
c.close() c.close()
d.close() d.close()
#---------------------------------------------------------------------- #----------------------------------------------------------------------