[Python-3000-checkins] r51564 - python/branches/p3yk/Lib/bsddb/test/test_basics.py python/branches/p3yk/Lib/bsddb/test/test_dbshelve.py
guido.van.rossum
python-3000-checkins at python.org
Thu Aug 24 20:19:44 CEST 2006
Author: guido.van.rossum
Date: Thu Aug 24 20:19:44 2006
New Revision: 51564
Modified:
python/branches/p3yk/Lib/bsddb/test/test_basics.py
python/branches/p3yk/Lib/bsddb/test/test_dbshelve.py
Log:
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.
Modified: python/branches/p3yk/Lib/bsddb/test/test_basics.py
==============================================================================
--- python/branches/p3yk/Lib/bsddb/test/test_basics.py (original)
+++ python/branches/p3yk/Lib/bsddb/test/test_basics.py Thu Aug 24 20:19:44 2006
@@ -697,7 +697,7 @@
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
Modified: python/branches/p3yk/Lib/bsddb/test/test_dbshelve.py
==============================================================================
--- python/branches/p3yk/Lib/bsddb/test/test_dbshelve.py (original)
+++ python/branches/p3yk/Lib/bsddb/test/test_dbshelve.py Thu Aug 24 20:19:44 2006
@@ -23,11 +23,24 @@
# 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 @@
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)
More information about the Python-3000-checkins
mailing list