[Zope3-checkins] CVS: ZODB4/src/zodb/storage/tests - base.py:1.2.4.2

Barry Warsaw barry@wooz.org
Thu, 23 Jan 2003 13:58:39 -0500


Update of /cvs-repository/ZODB4/src/zodb/storage/tests
In directory cvs.zope.org:/tmp/cvs-serv29533

Modified Files:
      Tag: new-pickle-branch
	base.py 
Log Message:
Refactor the way storages are created for the Berkeley based
storages.

_homedir(): Gives directory to create the storage in

_config(): Returns the BerkeleyConfig object to pass into the ctor

_zap_dbhome(), _mk_dbhome(): Changed to use these two new methods

open(): Creates the storage and assigns it to self._storage

setUp(), tearDown(): Use these.


=== ZODB4/src/zodb/storage/tests/base.py 1.2.4.1 => 1.2.4.2 ===
--- ZODB4/src/zodb/storage/tests/base.py:1.2.4.1	Tue Jan 21 11:20:40 2003
+++ ZODB4/src/zodb/storage/tests/base.py	Thu Jan 23 13:58:36 2003
@@ -214,7 +214,8 @@
 
 
 class BerkeleyTestBase(StorageTestBase):
-    def _zap_dbhome(self, dir):
+    def _zap_dbhome(self):
+        dir = self._homedir()
         # If the tests exited with any uncommitted objects, they'll blow up
         # subsequent tests because the next transaction commit will try to
         # commit those object.  But they're tied to closed databases, so
@@ -228,26 +229,36 @@
                 raise
 
     def _mk_dbhome(self, dir):
-        # Checkpointing just slows the tests down because we have to wait for
-        # the thread to properly shutdown.  This can take up to 10 seconds, so
-        # for the purposes of the test suite we shut off this thread.
-        config = BerkeleyConfig()
-        config.interval = 0
         os.mkdir(dir)
         try:
-            return self.ConcreteStorage(dir, config=config)
+            self.open(dir)
         except:
             self._zap_dbhome(dir)
             raise
 
+    def _config(self):
+        # Checkpointing just slows the tests down because we have to wait for
+        # the thread to properly shutdown.  This can take up to 10 seconds, so
+        # for the purposes of the test suite we shut off this thread.
+        config = BerkeleyConfig()
+        config.interval = 0
+        return config
+
+    def _homedir(self):
+        return DBHOME
+
+    def open(self):
+        self._storage = self.ConcreteStorage(
+            self._homedir(), config=self._config())
+
     def setUp(self):
         StorageTestBase.setUp(self)
-        self._zap_dbhome(DBHOME)
-        self._storage = self._mk_dbhome(DBHOME)
+        self._zap_dbhome()
+        self.open()
 
     def tearDown(self):
         StorageTestBase.tearDown(self)
-        self._zap_dbhome(DBHOME)
+        self._zap_dbhome()