[Zodb-checkins] CVS: Packages/bsddb3Storage - test_commitlog.py:1.5
barry@digicool.com
barry@digicool.com
Mon, 23 Apr 2001 23:35:38 -0400 (EDT)
Update of /cvs-repository/Packages/bsddb3Storage/test
In directory korak:/tmp/cvs-serv5289
Modified Files:
test_commitlog.py
Log Message:
Fix some tests for commit log turd detection. Specifically,
checkCreateWithFilename(), checkCloseDoesUnlink(), checkDel(): Don't
unlink explicitly, but assert that the file is unlinked after close.
BaseSetupTearDown.tearDown(): It's okay if the tear down unlink fails
because the file already doesn't exist.
suite(): Use makeSuite.
--- Updated File test_commitlog.py in package Packages/bsddb3Storage --
--- test_commitlog.py 2001/04/16 20:52:12 1.4
+++ test_commitlog.py 2001/04/24 03:35:38 1.5
@@ -1,6 +1,7 @@
# Test the operation of the CommitLog classes
import os
+import errno
import unittest
import CommitLog
@@ -40,27 +41,19 @@
CommitLog.CommitLog, fp)
finally:
fp.close()
- os.unlink(filename)
+ assert not os.path.exists(filename)
- def checkCloseNoUnlink(self):
+ def checkCloseDoesUnlink(self):
log = CommitLog.CommitLog()
filename = log.get_filename()
log.close()
- try:
- assert os.path.exists(filename)
- finally:
- os.unlink(filename)
- assert not os.path.exists(filename)
+ assert not os.path.exists(filename)
def checkDel(self):
log = CommitLog.CommitLog()
filename = log.get_filename()
del log
- try:
- assert os.path.exists(filename)
- finally:
- os.unlink(filename)
- assert not os.path.exists(filename)
+ assert not os.path.exists(filename)
@@ -69,7 +62,10 @@
self._log = CommitLog.CommitLog()
def tearDown(self):
- self._log.close(unlink=1)
+ try:
+ self._log.close(unlink=1)
+ except OSError, e:
+ if e.errno <> errno.ENOENT: raise
@@ -232,27 +228,11 @@
def suite():
suite = unittest.TestSuite()
- # Creation and closing
- suite.addTest(CreateCommitLogTest('checkCreateNoFile'))
- suite.addTest(CreateCommitLogTest('checkCreateWithFilename'))
- suite.addTest(CreateCommitLogTest('checkCreateWithFileobj'))
- suite.addTest(CreateCommitLogTest('checkCloseNoUnlink'))
- suite.addTest(CreateCommitLogTest('checkDel'))
- # State transitions
- suite.addTest(CommitLogStateTransitionTest('checkProperStart'))
- suite.addTest(CommitLogStateTransitionTest('checkAppendSetsOpen'))
- suite.addTest(CommitLogStateTransitionTest('checkPromiseSetsPromise'))
- suite.addTest(CommitLogStateTransitionTest('checkBadDoublePromise'))
- suite.addTest(CommitLogStateTransitionTest('checkFinishSetsStart'))
- # Base class for storing and loading
- suite.addTest(LowLevelStoreAndLoadTest('checkOneStoreAndLoad'))
- suite.addTest(LowLevelStoreAndLoadTest('checkTenStoresAndLoads'))
- # PacklessLog API
- suite.addTest(PacklessLogTest('checkOneStoreAndLoad'))
- suite.addTest(PacklessLogTest('checkTenStoresAndLoads'))
- # FullLog API
- suite.addTest(FullLogTest('checkOneStoreAndLoad'))
- suite.addTest(FullLogTest('checkOtherWriteMethods'))
+ suite.addTest(unittest.makeSuite(CreateCommitLogTest, 'check'))
+ suite.addTest(unittest.makeSuite(CommitLogStateTransitionTest, 'check'))
+ suite.addTest(unittest.makeSuite(LowLevelStoreAndLoadTest, 'check'))
+ suite.addTest(unittest.makeSuite(PacklessLogTest, 'check'))
+ suite.addTest(unittest.makeSuite(FullLogTest, 'check'))
return suite