Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9149aeb

Browse files
committed
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.
1 parent a21bdea commit 9149aeb

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

Lib/bsddb/test/test_recno.py

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,19 @@
1-
"""
2-
TestCases for exercising a Recno DB.
1+
"""TestCases for exercising a Recno DB.
32
"""
43

54
import os
65
import sys
7-
import string
6+
import errno
87
import tempfile
98
from pprint import pprint
109
import unittest
1110

1211
from bsddb import db
13-
1412
from test_all import verbose
1513

14+
letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
15+
16+
1617
#----------------------------------------------------------------------
1718

1819
class SimpleRecnoTestCase(unittest.TestCase):
@@ -22,16 +23,14 @@ def setUp(self):
2223
def tearDown(self):
2324
try:
2425
os.remove(self.filename)
25-
except os.error:
26-
pass
27-
28-
26+
except OSError, e:
27+
if e.errno <> errno.EEXIST: raise
2928

3029
def test01_basic(self):
3130
d = db.DB()
3231
d.open(self.filename, db.DB_RECNO, db.DB_CREATE)
3332

34-
for x in string.ascii_letters:
33+
for x in letters:
3534
recno = d.append(x * 60)
3635
assert type(recno) == type(0)
3736
assert recno >= 1
@@ -77,7 +76,6 @@ def test01_basic(self):
7776
assert type(keys[0]) == type(123)
7877
assert len(keys) == len(d)
7978

80-
8179
items = d.items()
8280
if verbose:
8381
pprint(items)
@@ -164,7 +162,6 @@ def test01_basic(self):
164162
c.close()
165163
d.close()
166164

167-
168165
def test02_WithSource(self):
169166
"""
170167
A Recno file that is given a "backing source file" is essentially a
@@ -220,15 +217,14 @@ def test02_WithSource(self):
220217
assert text.split('\n') == \
221218
"The quick reddish-brown fox jumped over the comatose dog".split()
222219

223-
224220
def test03_FixedLength(self):
225221
d = db.DB()
226222
d.set_re_len(40) # fixed length records, 40 bytes long
227223
d.set_re_pad('-') # sets the pad character...
228224
d.set_re_pad(45) # ...test both int and char
229225
d.open(self.filename, db.DB_RECNO, db.DB_CREATE)
230226

231-
for x in string.ascii_letters:
227+
for x in letters:
232228
d.append(x * 35) # These will be padded
233229

234230
d.append('.' * 40) # this one will be exact
@@ -251,6 +247,7 @@ def test03_FixedLength(self):
251247
c.close()
252248
d.close()
253249

250+
254251
#----------------------------------------------------------------------
255252

256253

0 commit comments

Comments
 (0)