[Zodb-checkins] CVS: ZODB3/ZEO/tests - testZEO.py:1.56
Barry Warsaw
barry@wooz.org
Tue, 10 Dec 2002 16:48:04 -0500
Update of /cvs-repository/ZODB3/ZEO/tests
In directory cvs.zope.org:/tmp/cvs-serv20207
Modified Files:
testZEO.py
Log Message:
removefs(): We don't need this any more as we'll use the storage
module function cleanup() which was added to FileStorage and
BerkeleyBase.
UnixTests.getStorage(): Return a ZConfig string instead of a tuple of
a class name and an argument list.
BDBTests: Simple extension to UnixTests to test using Berkeley
storages with ZEO.
WindowsTest: Derive from UnixTests and remove getStorageInfo() and
delStorage().
Add BDBTests if we can import Full.
=== ZODB3/ZEO/tests/testZEO.py 1.55 => 1.56 ===
--- ZODB3/ZEO/tests/testZEO.py:1.55 Fri Oct 4 20:35:25 2002
+++ ZODB3/ZEO/tests/testZEO.py Tue Dec 10 16:48:04 2002
@@ -30,22 +30,6 @@
from ZODB.tests.MinPO import MinPO
from ZODB.tests.StorageTestBase import zodb_unpickle
-# Handle potential absence of removefs
-try:
- from ZODB.tests.StorageTestBase import removefs
-except ImportError:
- # for compatibility with Zope 2.5 &c.
- import errno
-
- def removefs(base):
- """Remove all files created by FileStorage with path base."""
- for ext in '', '.old', '.tmp', '.lock', '.index', '.pack':
- path = base + ext
- try:
- os.remove(path)
- except os.error, err:
- if err[0] != errno.ENOENT:
- raise
# ZODB test mixin classes
from ZODB.tests import StorageTestBase, BasicStorage, VersionStorage, \
@@ -67,8 +51,8 @@
def invalidate(self, *args):
pass
-class MiscZEOTests:
+class MiscZEOTests:
"""ZEO tests that don't fit in elsewhere."""
def checkLargeUpdate(self):
@@ -97,10 +81,10 @@
finally:
storage2.close()
+
class GenericTests(
# Base class for all ZODB tests
StorageTestBase.StorageTestBase,
-
# ZODB test mixin classes (in the same order as imported)
BasicStorage.BasicStorage,
VersionStorage.VersionStorage,
@@ -113,13 +97,13 @@
RevisionStorage.RevisionStorage,
MTStorage.MTStorage,
ReadOnlyStorage.ReadOnlyStorage,
-
# ZEO test mixin classes (in the same order as imported)
Cache.StorageWithCache,
Cache.TransUndoStorageWithCache,
CommitLockTests.CommitLockTests,
ThreadTests.ThreadTests,
- MiscZEOTests # Locally defined (see above)
+ # Locally defined (see above)
+ MiscZEOTests
):
"""Combine tests from various origins in one class."""
@@ -141,6 +125,7 @@
if hasattr(ZODB, "__version__"):
ReadOnlyStorage.ReadOnlyStorage.checkWriteMethods(self)
+
class UnixTests(GenericTests):
"""Add Unix-specific scaffolding to the generic test suite."""
@@ -162,19 +147,47 @@
self.delStorage()
def getStorage(self):
- self.__fs_base = tempfile.mktemp()
- return 'FileStorage', (self.__fs_base, '1')
+ filename = self.__fs_base = tempfile.mktemp()
+ # Return a 1-tuple
+ return """\
+ <Storage>
+ type FileStorage
+ file_name %s
+ create yes
+ </Storage>
+ """ % filename,
+
+ def delStorage(self):
+ from ZODB.FileStorage import cleanup
+ cleanup(self.__fs_base)
+
+
+class BDBTests(UnixTests):
+
+ """Add Berkeley storage tests (not sure if these are Unix specific)."""
+
+ def getStorage(self):
+ self._envdir = tempfile.mktemp()
+ # Return a 1-tuple
+ return """\
+ <Storage>
+ type Full
+ name %s
+ </Storage>
+ """ % self._envdir,
def delStorage(self):
- removefs(self.__fs_base)
+ from bsddb3Storage.BerkeleyBase import cleanup
+ cleanup(self._envdir)
+
-class WindowsTests(GenericTests):
+class WindowsTests(UnixTests):
"""Add Windows-specific scaffolding to the generic test suite."""
def setUp(self):
zLOG.LOG("testZEO", zLOG.INFO, "setUp() %s" % self.id())
- args = self.getStorageInfo()
+ args = self.getStorage()
name = args[0]
args = args[1]
zeo_addr, self.test_addr, self.test_pid = \
@@ -192,12 +205,6 @@
time.sleep(0.5)
self.delStorage()
- def getStorageInfo(self):
- self.__fs_base = tempfile.mktemp()
- return 'FileStorage', (self.__fs_base, '1') # create=1
-
- def delStorage(self):
- removefs(self.__fs_base)
if os.name == "posix":
test_classes = [UnixTests]
@@ -206,8 +213,15 @@
else:
raise RuntimeError, "unsupported os: %s" % os.name
-def test_suite():
+try:
+ from bsddb3Storage.Full import Full
+except ImportError:
+ pass
+else:
+ test_classes.append(BDBTests)
+
+def test_suite():
# shutup warnings about mktemp
import warnings
warnings.filterwarnings("ignore", "mktemp")
@@ -217,6 +231,7 @@
sub = unittest.makeSuite(klass, 'check')
suite.addTest(sub)
return suite
+
if __name__ == "__main__":
unittest.main(defaultTest='test_suite')