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

Barry Warsaw barry@wooz.org
Mon, 23 Dec 2002 17:00:14 -0500


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

Modified Files:
      Tag: NameGeddon-branch
	base.py 
Log Message:
fleb


=== Zope3/src/zodb/storage/tests/base.py 1.1.2.1 => 1.1.2.2 ===
--- Zope3/src/zodb/storage/tests/base.py:1.1.2.1	Mon Dec 23 14:30:50 2002
+++ Zope3/src/zodb/storage/tests/base.py	Mon Dec 23 17:00:12 2002
@@ -12,109 +12,6 @@
 # 
 ##############################################################################
 
-# Base class for unit tests at the ZODB layer
-
-import os
-import errno
-
-from zodb.db import DB
-from transaction import get_transaction
-
-
-DBHOME = 'test-db'
-
-
-
-class ZODBTestBase(BerkeleyTestBase):
-    def setUp(self):
-        BerkeleyTestBase.setUp(self)
-        self._db = None
-        try:
-            self._db = DB(self._storage)
-            self._conn = self._db.open()
-            self._root = self._conn.root()
-        except:
-            self.tearDown()
-            raise
-
-    def _close(self):
-        if self._db is not None:
-            self._db.close()
-            self._db = self._storage = self._conn = self._root = None
-
-    def tearDown(self):
-        # 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
-        # that's broken.  Aborting the transaction now saves us the headache.
-        try:
-            get_transaction().abort()
-            self._close()
-        finally:
-            BerkeleyTestBase.tearDown(self)
-
-
-
-# Basic test framework class for both the Full and Minimal Berkeley storages
-
-import os
-import errno
-
-from zodb.storage.base import BerkeleyConfig
-
-
-DBHOME = 'test-db'
-
-
-
-class BerkeleyTestBase(StorageTestBase):
-    def _zap_dbhome(self, dir):
-        # 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
-        # that's broken.  Aborting the transaction now saves us the headache.
-        try:
-            for file in os.listdir(dir):
-                os.unlink(os.path.join(dir, file))
-            os.removedirs(dir)
-        except OSError, e:
-            if e.errno <> errno.ENOENT:
-                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)
-        except:
-            self._zap_dbhome(dir)
-            raise
-
-    def setUp(self):
-        StorageTestBase.setUp(self)
-        self._zap_dbhome(DBHOME)
-        self._storage = self._mk_dbhome(DBHOME)
-
-    def tearDown(self):
-        StorageTestBase.tearDown(self)
-        self._zap_dbhome(DBHOME)
-
-
-
-class MinimalTestBase(BerkeleyTestBase):
-    from zodb.storage.bdbminimal import BDBMinimalStorage
-    ConcreteStorage = BDBMinimalStorage
-
-
-class FullTestBase(BerkeleyTestBase):
-    from zodb.storage.bdbfull import BDBFullStorage
-    ConcreteStorage = BDBFullStorage
-
-
 """Provide a mixin base class for storage tests.
 
 The StorageTestBase class provides basic setUp() and tearDown()
@@ -301,3 +198,105 @@
         self._storage.tpc_vote(t)
         self._storage.tpc_finish(t)
         return oids
+
+
+# Base class for unit tests at the ZODB layer
+
+import os
+import errno
+
+from zodb.db import DB
+from transaction import get_transaction
+
+
+DBHOME = 'test-db'
+
+
+# Basic test framework class for both the Full and Minimal Berkeley storages
+
+import os
+import errno
+
+from zodb.storage.base import BerkeleyConfig
+
+
+DBHOME = 'test-db'
+
+
+
+class BerkeleyTestBase(StorageTestBase):
+    def _zap_dbhome(self, dir):
+        # 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
+        # that's broken.  Aborting the transaction now saves us the headache.
+        try:
+            for file in os.listdir(dir):
+                os.unlink(os.path.join(dir, file))
+            os.removedirs(dir)
+        except OSError, e:
+            if e.errno <> errno.ENOENT:
+                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)
+        except:
+            self._zap_dbhome(dir)
+            raise
+
+    def setUp(self):
+        StorageTestBase.setUp(self)
+        self._zap_dbhome(DBHOME)
+        self._storage = self._mk_dbhome(DBHOME)
+
+    def tearDown(self):
+        StorageTestBase.tearDown(self)
+        self._zap_dbhome(DBHOME)
+
+
+
+class MinimalTestBase(BerkeleyTestBase):
+    from zodb.storage.bdbminimal import BDBMinimalStorage
+    ConcreteStorage = BDBMinimalStorage
+
+
+class FullTestBase(BerkeleyTestBase):
+    from zodb.storage.bdbfull import BDBFullStorage
+    ConcreteStorage = BDBFullStorage
+
+
+
+class ZODBTestBase(BerkeleyTestBase):
+    def setUp(self):
+        BerkeleyTestBase.setUp(self)
+        self._db = None
+        try:
+            self._db = DB(self._storage)
+            self._conn = self._db.open()
+            self._root = self._conn.root()
+        except:
+            self.tearDown()
+            raise
+
+    def _close(self):
+        if self._db is not None:
+            self._db.close()
+            self._db = self._storage = self._conn = self._root = None
+
+    def tearDown(self):
+        # 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
+        # that's broken.  Aborting the transaction now saves us the headache.
+        try:
+            get_transaction().abort()
+            self._close()
+        finally:
+            BerkeleyTestBase.tearDown(self)