summaryrefslogtreecommitdiffstats
path: root/Lib/bsddb/test/test_compat.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2007-08-08 22:08:30 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2007-08-08 22:08:30 (GMT)
commit918f49e645474382251bfddbb0a2e030051083ef (patch)
tree01fada4bbee6dd26f5503a7a7295b1c9f9f63a9c /Lib/bsddb/test/test_compat.py
parenteb29e9ab2b037db198591a9cacb5993385c7f83d (diff)
downloadcpython-918f49e645474382251bfddbb0a2e030051083ef.zip
cpython-918f49e645474382251bfddbb0a2e030051083ef.tar.gz
cpython-918f49e645474382251bfddbb0a2e030051083ef.tar.bz2
Fix most of the bsddb3 tests.
Diffstat (limited to 'Lib/bsddb/test/test_compat.py')
-rw-r--r--Lib/bsddb/test/test_compat.py45
1 files changed, 20 insertions, 25 deletions
diff --git a/Lib/bsddb/test/test_compat.py b/Lib/bsddb/test/test_compat.py
index 2908844..751a2bb 100644
--- a/Lib/bsddb/test/test_compat.py
+++ b/Lib/bsddb/test/test_compat.py
@@ -9,12 +9,7 @@ import tempfile
from .test_all import verbose
-try:
- # For Pythons w/distutils pybsddb
- from bsddb3 import db, hashopen, btopen, rnopen
-except ImportError:
- # For Python 2.3
- from bsddb import db, hashopen, btopen, rnopen
+from bsddb import db, hashopen, btopen, rnopen
class CompatibilityTestCase(unittest.TestCase):
@@ -41,31 +36,31 @@ class CompatibilityTestCase(unittest.TestCase):
f = rnopen(self.filename, 'c')
for x in range(len(data)):
- f[x+1] = data[x]
+ f[x+1] = data[x].encode("ascii")
getTest = (f[1], f[2], f[3])
if verbose:
print('%s %s %s' % getTest)
- assert getTest[1] == 'quick', 'data mismatch!'
+ assert getTest[1] == b'quick', 'data mismatch!'
rv = f.set_location(3)
- if rv != (3, 'brown'):
+ if rv != (3, b'brown'):
self.fail('recno database set_location failed: '+repr(rv))
- f[25] = 'twenty-five'
+ f[25] = b'twenty-five'
f.close()
del f
f = rnopen(self.filename, 'w')
- f[20] = 'twenty'
+ f[20] = b'twenty'
def noRec(f):
rec = f[15]
self.assertRaises(KeyError, noRec, f)
def badKey(f):
- rec = f['a string']
+ rec = f[b'a string']
self.assertRaises(TypeError, badKey, f)
del f[3]
@@ -101,20 +96,20 @@ class CompatibilityTestCase(unittest.TestCase):
else:
if verbose: print("truth test: false")
- f['0'] = ''
- f['a'] = 'Guido'
- f['b'] = 'van'
- f['c'] = 'Rossum'
- f['d'] = 'invented'
+ f[b'0'] = b''
+ f[b'a'] = b'Guido'
+ f[b'b'] = b'van'
+ f[b'c'] = b'Rossum'
+ f[b'd'] = b'invented'
# 'e' intentionally left out
- f['f'] = 'Python'
+ f[b'f'] = b'Python'
if verbose:
print('%s %s %s' % (f['a'], f['b'], f['c']))
if verbose:
print('key ordering...')
start = f.set_location(f.first()[0])
- if start != ('0', ''):
+ if start != (b'0', b''):
self.fail("incorrect first() result: "+repr(start))
while 1:
try:
@@ -126,17 +121,17 @@ class CompatibilityTestCase(unittest.TestCase):
if verbose:
print(rec)
- assert f.has_key('f'), 'Error, missing key!'
+ assert f.has_key(b'f'), 'Error, missing key!'
# test that set_location() returns the next nearest key, value
# on btree databases and raises KeyError on others.
if factory == btopen:
- e = f.set_location('e')
- if e != ('f', 'Python'):
+ e = f.set_location(b'e')
+ if e != (b'f', b'Python'):
self.fail('wrong key,value returned: '+repr(e))
else:
try:
- e = f.set_location('e')
+ e = f.set_location(b'e')
except KeyError:
pass
else:
@@ -160,7 +155,7 @@ class CompatibilityTestCase(unittest.TestCase):
if verbose:
print('modification...')
f = factory(self.filename, 'w')
- f['d'] = 'discovered'
+ f[b'd'] = b'discovered'
if verbose:
print('access...')
@@ -170,7 +165,7 @@ class CompatibilityTestCase(unittest.TestCase):
print(word)
def noRec(f):
- rec = f['no such key']
+ rec = f[b'no such key']
self.assertRaises(KeyError, noRec, f)
def badKey(f):