summaryrefslogtreecommitdiffstats
path: root/Lib/bsddb
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2003-01-10 19:28:15 (GMT)
committerBarry Warsaw <barry@python.org>2003-01-10 19:28:15 (GMT)
commit9149aeb842abe465c7afdacb0c9535546373302c (patch)
tree7983011c82fb47df1914fb86efeac4b77f65d13c /Lib/bsddb
parenta21bdeae51a87ebf4cdfd5767d46fc3007b25eee (diff)
downloadcpython-9149aeb842abe465c7afdacb0c9535546373302c.zip
cpython-9149aeb842abe465c7afdacb0c9535546373302c.tar.gz
cpython-9149aeb842abe465c7afdacb0c9535546373302c.tar.bz2
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.
Diffstat (limited to 'Lib/bsddb')
-rw-r--r--Lib/bsddb/test/test_recno.py23
1 files changed, 10 insertions, 13 deletions
diff --git a/Lib/bsddb/test/test_recno.py b/Lib/bsddb/test/test_recno.py
index b3a999e..ffdb76b 100644
--- a/Lib/bsddb/test/test_recno.py
+++ b/Lib/bsddb/test/test_recno.py
@@ -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()
+
#----------------------------------------------------------------------