[Zodb-checkins] CVS: StandaloneZODB/bsddb3Storage/bsddb3Storage/tests - test_commitlog.py:1.8 test_create.py:1.10 test_virgin.py:1.9 test_zodb_simple.py:1.6
Barry Warsaw
barry@wooz.org
Fri, 21 Sep 2001 16:56:43 -0400
Update of /cvs-repository/StandaloneZODB/bsddb3Storage/bsddb3Storage/tests
In directory cvs.zope.org:/tmp/cvs-serv27707/bsddb3Storage/bsddb3Storage/tests
Modified Files:
test_commitlog.py test_create.py test_virgin.py
test_zodb_simple.py
Log Message:
Don't use assert keyword to ensure that a test passes; use
self.assertEqual() and friends since this gives much better output.
=== StandaloneZODB/bsddb3Storage/bsddb3Storage/tests/test_commitlog.py 1.7 => 1.8 ===
class CreateCommitLogTest(unittest.TestCase):
def checkCreateNoFile(self):
+ unless = self.failUnless
log = CommitLog.CommitLog()
filename = log.get_filename()
try:
- assert os.path.exists(filename)
+ unless(os.path.exists(filename))
finally:
log.close(unlink=1)
- assert not os.path.exists(filename)
+ unless(not os.path.exists(filename))
def checkCreateWithFilename(self):
+ unless = self.failUnless
filename = 'commit.log'
log = CommitLog.CommitLog(filename)
try:
- assert os.path.exists(filename)
+ unless(os.path.exists(filename))
finally:
log.close(unlink=1)
- assert not os.path.exists(filename)
+ unless(not os.path.exists(filename))
def checkCreateWithFileobj(self):
filename = 'commit.log'
@@ -41,19 +43,19 @@
CommitLog.CommitLog, fp)
finally:
fp.close()
- assert not os.path.exists(filename)
+ self.failUnless(not os.path.exists(filename))
def checkCloseDoesUnlink(self):
log = CommitLog.CommitLog()
filename = log.get_filename()
log.close()
- assert not os.path.exists(filename)
+ self.failUnless(not os.path.exists(filename))
def checkDel(self):
log = CommitLog.CommitLog()
filename = log.get_filename()
del log
- assert not os.path.exists(filename)
+ self.failUnless(not os.path.exists(filename))
@@ -115,14 +117,17 @@
class LowLevelStoreAndLoadTest(BaseSetupTearDown):
def checkOneStoreAndLoad(self):
+ eq = self.assertEqual
self._log.start()
self._log._append('x', 'ignore')
self._log.promise()
x, ignore = self._log._next()
- assert x == 'x' and ignore == 'ignore'
- assert None == self._log._next()
+ eq(x, 'x')
+ eq(ignore, 'ignore')
+ eq(self._log._next(), None)
def checkTenStoresAndLoads(self):
+ eq = self.assertEqual
self._log.start()
for k, v in Gen():
self._log._append(k, v)
@@ -133,7 +138,8 @@
if rec is None:
break
c, i = g()
- assert rec[0] == c and rec[1] == i
+ eq(rec[0], c)
+ eq(rec[1], i)
self.assertRaises(IndexError, g)
@@ -144,13 +150,16 @@
self._log.start()
def checkOneStoreAndLoad(self):
+ eq = self.assertEqual
self._log.write_object(oid=10, pickle='ignore')
self._log.promise()
oid, pickle = self._log.next()
- assert oid == 10 and pickle == 'ignore'
- assert None == self._log.next()
+ eq(oid, 10)
+ eq(pickle, 'ignore')
+ eq(self._log.next(), None)
def checkTenStoresAndLoads(self):
+ eq = self.assertEqual
for k, v in Gen():
self._log.write_object(v, k*10)
self._log.promise()
@@ -161,7 +170,8 @@
break
c, i = g()
oid, pickle = rec
- assert oid == i and pickle == c*10
+ eq(oid, i)
+ eq(pickle, c*10)
self.assertRaises(IndexError, g)
@@ -172,6 +182,7 @@
self._log.start()
def checkOneStoreAndLoad(self):
+ eq = self.assertEqual
oid = 10
vid = 8
nvrevid = 0
@@ -180,14 +191,16 @@
self._log.write_object(oid, vid, nvrevid, pickle, prevrevid)
self._log.promise()
rec = self._log.next()
- assert rec
+ self.failUnless(rec)
key, rec = rec
- assert key == 'o' and len(rec) == 6
- assert rec[0] == oid and rec[1] == vid and rec[2] == nvrevid
- assert rec[3] == '' and rec[4] == pickle and rec[5] == prevrevid
- assert None == self._log.next()
+ eq(key, 'o')
+ eq(len(rec), 6)
+ eq(rec, (oid, vid, nvrevid, '', pickle, prevrevid))
+ eq(self._log.next(), None)
def checkOtherWriteMethods(self):
+ eq = self.assertEqual
+ unless = self.failUnless
oid = 10
vid = 1
nvrevid = 0
@@ -202,27 +215,29 @@
self._log.write_discard_version(vid)
self._log.promise()
rec = self._log.next()
- assert rec
+ unless(rec)
key, rec = rec
- assert key == 'o' and len(rec) == 6
- assert rec[0] == oid and rec[1] == zero and rec[2] == zero
- assert rec[3] == lrevid and rec[4] == '' and rec[5] == prevrevid
+ eq(key, 'o')
+ eq(len(rec), 6)
+ eq(rec, (oid, zero, zero, lrevid, '', prevrevid))
rec = self._log.next()
- assert rec
+ unless(rec)
key, rec = rec
- assert key == 'o' and len(rec) == 6
- assert rec[0] == oid and rec[1] == vid and rec[2] == nvrevid
- assert rec[3] == lrevid and rec[4] == '' and rec[5] == prevrevid
+ eq(key, 'o')
+ eq(len(rec), 6)
+ eq(rec, (oid, vid, nvrevid, lrevid, '', prevrevid))
rec = self._log.next()
- assert rec
+ unless(rec)
key, rec = rec
- assert key == 'v' and len(rec) == 2
- assert rec[0] == version and rec[1] == vid
+ eq(key, 'v')
+ eq(len(rec), 2)
+ eq(rec, (version, vid))
rec = self._log.next()
- assert rec
+ unless(rec)
key, rec = rec
- assert key == 'd' and len(rec) == 1
- assert rec[0] == vid
+ eq(key, 'd')
+ eq(len(rec), 1)
+ eq(rec, (vid,))
=== StandaloneZODB/bsddb3Storage/bsddb3Storage/tests/test_create.py 1.9 => 1.10 ===
class TestMixin:
def checkDBHomeExists(self):
- assert os.path.isdir(BerkeleyTestBase.DBHOME)
+ self.failUnless(os.path.isdir(BerkeleyTestBase.DBHOME))
class MinimalCreateTest(BerkeleyTestBase.BerkeleyTestBase,
@@ -33,16 +33,17 @@
# Now close the current storage and re-open it
self._storage.close()
self._storage = self.ConcreteStorage(BerkeleyTestBase.DBHOME)
- assert self._storage.modifiedInVersion(oid) == version
+ self.assertEqual(self._storage.modifiedInVersion(oid), version)
def checkOpenAddVersion(self):
+ eq = self.assertEqual
version1 = 'test-version'
oid1 = self._storage.new_oid()
revid = self._dostore(oid1, data=7, version=version1)
# Now close the current storage and re-open it
self._storage.close()
self._storage = self.ConcreteStorage(BerkeleyTestBase.DBHOME)
- assert self._storage.modifiedInVersion(oid1) == version1
+ eq(self._storage.modifiedInVersion(oid1), version1)
# Now create a 2nd version string, then close/reopen
version2 = 'new-version'
oid2 = self._storage.new_oid()
@@ -50,9 +51,9 @@
# Now close the current storage and re-open it
self._storage.close()
self._storage = self.ConcreteStorage(BerkeleyTestBase.DBHOME)
- assert self._storage.modifiedInVersion(oid1) == version1
+ eq(self._storage.modifiedInVersion(oid1), version1)
# Now create a 2nd version string, then close/reopen
- assert self._storage.modifiedInVersion(oid2) == version2
+ eq(self._storage.modifiedInVersion(oid2), version2)
=== StandaloneZODB/bsddb3Storage/bsddb3Storage/tests/test_virgin.py 1.8 => 1.9 ===
class InsertMixin:
def checkIsEmpty(self):
- assert not self._root.has_key('names')
+ self.failUnless(not self._root.has_key('names'))
def checkNewInserts(self):
self._root['names'] = names = PersistentMapping()
=== StandaloneZODB/bsddb3Storage/bsddb3Storage/tests/test_zodb_simple.py 1.5 => 1.6 ===
class CommitAndRead:
def checkCommit(self):
- assert not self._root
+ self.failUnless(not self._root)
names = self._root['names'] = PersistentMapping()
names['Warsaw'] = 'Barry'
names['Hylton'] = 'Jeremy'
get_transaction().commit()
def checkReadAfterCommit(self):
+ eq = self.assertEqual
self.checkCommit()
names = self._root['names']
- assert names['Warsaw'] == 'Barry'
- assert names['Hylton'] == 'Jeremy'
- assert names.get('Drake') is None
+ eq(names['Warsaw'], 'Barry')
+ eq(names['Hylton'], 'Jeremy')
+ self.failUnless(names.get('Drake') is None)
def checkAbortAfterRead(self):
self.checkReadAfterCommit()
@@ -34,7 +35,7 @@
def checkReadAfterAbort(self):
self.checkAbortAfterRead()
names = self._root['names']
- assert names.get('Drake') is None
+ self.failUnless(names.get('Drake') is None)
def checkChangingCommits(self):
self.checkReadAfterAbort()
@@ -44,7 +45,7 @@
if timestamp is None:
timestamp = self._root['timestamp'] = 0
get_transaction().commit()
- assert now > timestamp + 3
+ self.failUnless(now > timestamp + 3)
self._root['timestamp'] = now
time.sleep(3)