Commit 8e8798e7 authored by Chris Withers's avatar Chris Withers

Changes to make BDBStorage tests display a message if they're run when BDBStorage is not available.

parent d8f18ad8
...@@ -18,7 +18,10 @@ ...@@ -18,7 +18,10 @@
import os import os
import errno import errno
import shutil import shutil
import sys
import unittest
import BDBStorage
from BDBStorage.BerkeleyBase import BerkeleyConfig from BDBStorage.BerkeleyBase import BerkeleyConfig
from ZODB.tests.StorageTestBase import StorageTestBase from ZODB.tests.StorageTestBase import StorageTestBase
...@@ -77,3 +80,18 @@ class MinimalTestBase(BerkeleyTestBase): ...@@ -77,3 +80,18 @@ class MinimalTestBase(BerkeleyTestBase):
class FullTestBase(BerkeleyTestBase): class FullTestBase(BerkeleyTestBase):
from BDBStorage import BDBFullStorage from BDBStorage import BDBFullStorage
ConcreteStorage = BDBFullStorage.BDBFullStorage ConcreteStorage = BDBFullStorage.BDBFullStorage
def makeSuite(*args,**kw):
prefix = kw.get('prefix','check')
level = kw.get('level')
suite = unittest.TestSuite()
if level:
suite.level = level
if BDBStorage.is_available:
for klass in args:
suite.addTest(unittest.makeSuite(klass, prefix))
else:
sys.stderr.write("BDBStorage not available, tests disabled\n")
return suite
...@@ -533,16 +533,15 @@ class TestMinimalClassicPackRaceCondition(RaceConditionBase): ...@@ -533,16 +533,15 @@ class TestMinimalClassicPackRaceCondition(RaceConditionBase):
def test_suite(): def test_suite():
suite = unittest.TestSuite() return BDBStorage.tests.BerkeleyTestBase.makeSuite(
suite.level = 2 TestAutopack,
if BDBStorage.is_available: TestAutomaticClassicPack,
suite.addTest(unittest.makeSuite(TestAutopack)) TestMinimalPack,
suite.addTest(unittest.makeSuite(TestAutomaticClassicPack)) TestFullClassicPackRaceCondition,
suite.addTest(unittest.makeSuite(TestMinimalPack)) TestMinimalClassicPackRaceCondition,
suite.addTest(unittest.makeSuite(TestFullClassicPackRaceCondition)) prefix='test',
suite.addTest(unittest.makeSuite(TestMinimalClassicPackRaceCondition)) level=2
return suite )
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -111,13 +111,14 @@ class OpenRecoveryTest(BerkeleyTestBase.FullTestBase): ...@@ -111,13 +111,14 @@ class OpenRecoveryTest(BerkeleyTestBase.FullTestBase):
def test_suite(): def test_suite():
suite = unittest.TestSuite() return BDBStorage.tests.BerkeleyTestBase.makeSuite(
if BDBStorage.is_available: MinimalCreateTest,
suite.addTest(unittest.makeSuite(MinimalCreateTest)) FullCreateTest,
suite.addTest(unittest.makeSuite(FullCreateTest)) FullOpenExistingTest,
suite.addTest(unittest.makeSuite(FullOpenExistingTest)) FullOpenCloseTest,
suite.addTest(unittest.makeSuite(FullOpenCloseTest)) OpenRecoveryTest,
suite.addTest(unittest.makeSuite(OpenRecoveryTest)) prefix='test'
)
return suite return suite
......
...@@ -77,13 +77,11 @@ class FullRecoveryTest(BerkeleyTestBase.FullTestBase, ...@@ -77,13 +77,11 @@ class FullRecoveryTest(BerkeleyTestBase.FullTestBase,
def test_suite(): def test_suite():
suite = unittest.TestSuite() return BDBStorage.tests.BerkeleyTestBase.makeSuite(
if BDBStorage.is_available: FullTest,
suite.addTest(unittest.makeSuite(FullTest, 'check')) FullRecoveryTest,
suite.addTest(unittest.makeSuite(FullRecoveryTest, 'check')) MinimalTest,
suite.addTest(unittest.makeSuite(MinimalTest, 'check')) )
return suite
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -46,12 +46,10 @@ class MinimalNewInsertsTest(ZODBTestBase, InsertMixin): ...@@ -46,12 +46,10 @@ class MinimalNewInsertsTest(ZODBTestBase, InsertMixin):
def test_suite(): def test_suite():
suite = unittest.TestSuite() return BDBStorage.tests.BerkeleyTestBase.makeSuite(
if BDBStorage.is_available: MinimalNewInsertsTest,
suite.addTest(unittest.makeSuite(MinimalNewInsertsTest, 'check')) FullNewInsertsTest,
suite.addTest(unittest.makeSuite(FullNewInsertsTest, 'check')) )
return suite
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -246,14 +246,12 @@ class WhiteboxHighLevelFull(ZODBTestBase): ...@@ -246,14 +246,12 @@ class WhiteboxHighLevelFull(ZODBTestBase):
def test_suite(): def test_suite():
suite = unittest.TestSuite() return BDBStorage.tests.BerkeleyTestBase.makeSuite(
if BDBStorage.is_available: WhiteboxLowLevelMinimal,
suite.addTest(unittest.makeSuite(WhiteboxLowLevelMinimal, 'check')) WhiteboxHighLevelMinimal,
suite.addTest(unittest.makeSuite(WhiteboxHighLevelMinimal, 'check')) WhiteboxLowLevelFull,
suite.addTest(unittest.makeSuite(WhiteboxLowLevelFull, 'check')) WhiteboxHighLevelFull,
suite.addTest(unittest.makeSuite(WhiteboxHighLevelFull, 'check')) )
return suite
if __name__ == '__main__': if __name__ == '__main__':
......
...@@ -78,13 +78,10 @@ class FullCommitAndRead(ZODBTestBase, CommitAndRead): ...@@ -78,13 +78,10 @@ class FullCommitAndRead(ZODBTestBase, CommitAndRead):
def test_suite(): def test_suite():
suite = unittest.TestSuite() return BDBStorage.tests.BerkeleyTestBase.makeSuite(
if BDBStorage.is_available: MinimalCommitAndRead,
suite.addTest(unittest.makeSuite(MinimalCommitAndRead, 'check')) FullCommitAndRead
suite.addTest(unittest.makeSuite(FullCommitAndRead, 'check')) )
return suite
if __name__ == '__main__': if __name__ == '__main__':
unittest.main(defaultTest='test_suite') unittest.main(defaultTest='test_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