summaryrefslogtreecommitdiff
path: root/Lib/bsddb/test/test_join.py
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2007-08-08 22:08:30 +0000
committerMartin v. Löwis <martin@v.loewis.de>2007-08-08 22:08:30 +0000
commit918f49e645474382251bfddbb0a2e030051083ef (patch)
tree01fada4bbee6dd26f5503a7a7295b1c9f9f63a9c /Lib/bsddb/test/test_join.py
parenteb29e9ab2b037db198591a9cacb5993385c7f83d (diff)
downloadcpython-git-918f49e645474382251bfddbb0a2e030051083ef.tar.gz
Fix most of the bsddb3 tests.
Diffstat (limited to 'Lib/bsddb/test/test_join.py')
-rw-r--r--Lib/bsddb/test/test_join.py22
1 files changed, 10 insertions, 12 deletions
diff --git a/Lib/bsddb/test/test_join.py b/Lib/bsddb/test/test_join.py
index 46178b08bb..0e41152626 100644
--- a/Lib/bsddb/test/test_join.py
+++ b/Lib/bsddb/test/test_join.py
@@ -15,12 +15,7 @@ except ImportError:
import unittest
from .test_all import verbose
-try:
- # For Pythons w/distutils pybsddb
- from bsddb3 import db, dbshelve
-except ImportError:
- # For Python 2.3
- from bsddb import db, dbshelve
+from bsddb import db, dbshelve, StringKeys
#----------------------------------------------------------------------
@@ -44,6 +39,9 @@ ColorIndex = [
('black', "shotgun"),
]
+def ASCII(s):
+ return s.encode("ascii")
+
class JoinTestCase(unittest.TestCase):
keytype = ''
@@ -72,13 +70,13 @@ class JoinTestCase(unittest.TestCase):
# create and populate primary index
priDB = db.DB(self.env)
priDB.open(self.filename, "primary", db.DB_BTREE, db.DB_CREATE)
- [priDB.put(*t) for t in ProductIndex]
+ [priDB.put(ASCII(k),ASCII(v)) for k,v in ProductIndex]
# create and populate secondary index
secDB = db.DB(self.env)
secDB.set_flags(db.DB_DUP | db.DB_DUPSORT)
secDB.open(self.filename, "secondary", db.DB_BTREE, db.DB_CREATE)
- [secDB.put(*t) for t in ColorIndex]
+ [secDB.put(ASCII(k),ASCII(v)) for k,v in ColorIndex]
sCursor = None
jCursor = None
@@ -87,7 +85,7 @@ class JoinTestCase(unittest.TestCase):
sCursor = secDB.cursor()
# Don't do the .set() in an assert, or you can get a bogus failure
# when running python -O
- tmp = sCursor.set('red')
+ tmp = sCursor.set(b'red')
assert tmp
# FIXME: jCursor doesn't properly hold a reference to its
@@ -95,11 +93,11 @@ class JoinTestCase(unittest.TestCase):
# can cause a crash.
jCursor = priDB.join([sCursor])
- if jCursor.get(0) != ('apple', "Convenience Store"):
+ if jCursor.get(0) != (b'apple', b"Convenience Store"):
self.fail("join cursor positioned wrong")
- if jCursor.join_item() != 'chainsaw':
+ if jCursor.join_item() != b'chainsaw':
self.fail("DBCursor.join_item returned wrong item")
- if jCursor.get(0)[0] != 'strawberry':
+ if jCursor.get(0)[0] != b'strawberry':
self.fail("join cursor returned wrong thing")
if jCursor.get(0): # there were only three red items to return
self.fail("join cursor returned too many items")