summaryrefslogtreecommitdiffstats
path: root/Lib/bsddb
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2006-08-24 18:19:44 (GMT)
committerGuido van Rossum <guido@python.org>2006-08-24 18:19:44 (GMT)
commite4ef3a6e6c5327c6e1a7a7667f0669aab92c6fd9 (patch)
tree1245ccde784625a425d0eb070b7f18a9a91a543a /Lib/bsddb
parent19960597adb65c9ecd33e4c3d320390eecd38625 (diff)
downloadcpython-e4ef3a6e6c5327c6e1a7a7667f0669aab92c6fd9.zip
cpython-e4ef3a6e6c5327c6e1a7a7667f0669aab92c6fd9.tar.gz
cpython-e4ef3a6e6c5327c6e1a7a7667f0669aab92c6fd9.tar.bz2
Fix the bsddb3 unit tests.
This essentially meant fixing one case where a list of custom objects was being sorted, and fixing one genuine bug where a method call was missing parentheses.
Diffstat (limited to 'Lib/bsddb')
-rw-r--r--Lib/bsddb/test/test_basics.py2
-rw-r--r--Lib/bsddb/test/test_dbshelve.py24
2 files changed, 19 insertions, 7 deletions
diff --git a/Lib/bsddb/test/test_basics.py b/Lib/bsddb/test/test_basics.py
index 7e6ba52..e0452df 100644
--- a/Lib/bsddb/test/test_basics.py
+++ b/Lib/bsddb/test/test_basics.py
@@ -697,7 +697,7 @@ class BasicTransactionTestCase(BasicTestCase):
for log in logs:
if verbose:
print 'log file: ' + log
- if db.version >= (4,2):
+ if db.version() >= (4,2):
logs = self.env.log_archive(db.DB_ARCH_REMOVE)
assert not logs
diff --git a/Lib/bsddb/test/test_dbshelve.py b/Lib/bsddb/test/test_dbshelve.py
index 002bda9..374ccd8 100644
--- a/Lib/bsddb/test/test_dbshelve.py
+++ b/Lib/bsddb/test/test_dbshelve.py
@@ -23,11 +23,24 @@ from .test_all import verbose
# We want the objects to be comparable so we can test dbshelve.values
# later on.
class DataClass:
+
def __init__(self):
self.value = random.random()
- def __cmp__(self, other):
- return cmp(self.value, other)
+ def __repr__(self):
+ return "DataClass(%r)" % self.value
+
+ def __eq__(self, other):
+ value = self.value
+ if isinstance(other, DataClass):
+ other = other.value
+ return value == other
+
+ def __lt__(self, other):
+ value = self.value
+ if isinstance(other, DataClass):
+ other = other.value
+ return value < other
class DBShelveTestCase(unittest.TestCase):
def setUp(self):
@@ -103,11 +116,10 @@ class DBShelveTestCase(unittest.TestCase):
print "%s: %s" % (key, value)
self.checkrec(key, value)
- dbvalues = d.values()
+ dbvalues = sorted(d.values(), key=lambda x: (str(type(x)), x))
assert len(dbvalues) == len(d.keys())
- values.sort()
- dbvalues.sort()
- assert values == dbvalues
+ values.sort(key=lambda x: (str(type(x)), x))
+ assert values == dbvalues, "%r != %r" % (values, dbvalues)
items = d.items()
assert len(items) == len(values)