Commit aa3de9c1 authored by Barry Warsaw's avatar Barry Warsaw

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.
parent 34b88faf
# Test the operation of the CommitLog classes
import os
import errno
import unittest
import CommitLog
......@@ -40,26 +41,18 @@ class CreateCommitLogTest(unittest.TestCase):
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)
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)
......@@ -69,7 +62,10 @@ class BaseSetupTearDown(unittest.TestCase):
self._log = CommitLog.CommitLog()
def tearDown(self):
try:
self._log.close(unlink=1)
except OSError, e:
if e.errno <> errno.ENOENT: raise
......@@ -232,27 +228,11 @@ class FullLogTest(BaseSetupTearDown):
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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment