From 918f49e645474382251bfddbb0a2e030051083ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20v=2E=20L=C3=B6wis?= Date: Wed, 8 Aug 2007 22:08:30 +0000 Subject: Fix most of the bsddb3 tests. --- Lib/bsddb/test/test_join.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'Lib/bsddb/test/test_join.py') 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") -- cgit v1.2.1