Commit bd066aff authored by Barry Warsaw's avatar Barry Warsaw

OpenRecoveryTest: New test for recovering from problems passing in a

bogus config object.
parent 6e8fbfb4
...@@ -17,8 +17,10 @@ ...@@ -17,8 +17,10 @@
import os import os
import time import time
import unittest import unittest
import BerkeleyTestBase
from bsddb3Storage.BerkeleyBase import BerkeleyConfig from bsddb3Storage.BerkeleyBase import BerkeleyConfig
from bsddb3Storage.tests import BerkeleyTestBase
from bsddb3Storage.Full import Full
...@@ -84,6 +86,23 @@ class FullOpenCloseTest(BerkeleyTestBase.FullTestBase): ...@@ -84,6 +86,23 @@ class FullOpenCloseTest(BerkeleyTestBase.FullTestBase):
time.sleep(20) time.sleep(20)
class OpenRecoveryTest(BerkeleyTestBase.FullTestBase):
def _mk_dbhome(self, dir):
self._dir = dir
def checkOpenWithBogusConfig(self):
class C: pass
c = C()
# This instance won't have the necessary attributes, so the creation
# will fail. We want to be sure that everything gets cleaned up
# enough to fix that and create a proper storage.
self.assertRaises(AttributeError, Full, self._dir, config=c)
c = BerkeleyConfig()
s = Full(self._dir, config=c)
s.close()
def test_suite(): def test_suite():
suite = unittest.TestSuite() suite = unittest.TestSuite()
...@@ -91,6 +110,7 @@ def test_suite(): ...@@ -91,6 +110,7 @@ def test_suite():
suite.addTest(unittest.makeSuite(FullCreateTest, 'check')) suite.addTest(unittest.makeSuite(FullCreateTest, 'check'))
suite.addTest(unittest.makeSuite(FullOpenExistingTest, 'check')) suite.addTest(unittest.makeSuite(FullOpenExistingTest, 'check'))
suite.addTest(unittest.makeSuite(FullOpenCloseTest, 'check')) suite.addTest(unittest.makeSuite(FullOpenCloseTest, 'check'))
suite.addTest(unittest.makeSuite(OpenRecoveryTest, 'check'))
return suite 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