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 sys
import string
import errno
import tempfile
from pprint import pprint
import unittest
from bsddb import db
from test_all import verbose
letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
#----------------------------------------------------------------------
class SimpleRecnoTestCase(unittest.TestCase):
@ -22,16 +23,14 @@ class SimpleRecnoTestCase(unittest.TestCase):
def tearDown(self):
try:
os.remove(self.filename)
except os.error:
pass
except OSError, e:
if e.errno <> errno.EEXIST: raise
def test01_basic(self):
d = db.DB()
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)
assert type(recno) == type(0)
assert recno >= 1
@ -77,7 +76,6 @@ class SimpleRecnoTestCase(unittest.TestCase):
assert type(keys[0]) == type(123)
assert len(keys) == len(d)
items = d.items()
if verbose:
pprint(items)
@ -164,7 +162,6 @@ class SimpleRecnoTestCase(unittest.TestCase):
c.close()
d.close()
def test02_WithSource(self):
"""
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') == \
"The quick reddish-brown fox jumped over the comatose dog".split()
def test03_FixedLength(self):
d = db.DB()
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.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('.' * 40) # this one will be exact
@ -251,6 +247,7 @@ class SimpleRecnoTestCase(unittest.TestCase):
c.close()
d.close()
#----------------------------------------------------------------------