Commit 9a471ad7 authored by Barry Warsaw's avatar Barry Warsaw

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.
parent e03754a5
...@@ -30,22 +30,6 @@ import ZODB ...@@ -30,22 +30,6 @@ import ZODB
from ZODB.tests.MinPO import MinPO from ZODB.tests.MinPO import MinPO
from ZODB.tests.StorageTestBase import zodb_unpickle 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 # ZODB test mixin classes
from ZODB.tests import StorageTestBase, BasicStorage, VersionStorage, \ from ZODB.tests import StorageTestBase, BasicStorage, VersionStorage, \
...@@ -67,8 +51,8 @@ class DummyDB: ...@@ -67,8 +51,8 @@ class DummyDB:
def invalidate(self, *args): def invalidate(self, *args):
pass pass
class MiscZEOTests:
class MiscZEOTests:
"""ZEO tests that don't fit in elsewhere.""" """ZEO tests that don't fit in elsewhere."""
def checkLargeUpdate(self): def checkLargeUpdate(self):
...@@ -97,10 +81,10 @@ class MiscZEOTests: ...@@ -97,10 +81,10 @@ class MiscZEOTests:
finally: finally:
storage2.close() storage2.close()
class GenericTests( class GenericTests(
# Base class for all ZODB tests # Base class for all ZODB tests
StorageTestBase.StorageTestBase, StorageTestBase.StorageTestBase,
# ZODB test mixin classes (in the same order as imported) # ZODB test mixin classes (in the same order as imported)
BasicStorage.BasicStorage, BasicStorage.BasicStorage,
VersionStorage.VersionStorage, VersionStorage.VersionStorage,
...@@ -113,13 +97,13 @@ class GenericTests( ...@@ -113,13 +97,13 @@ class GenericTests(
RevisionStorage.RevisionStorage, RevisionStorage.RevisionStorage,
MTStorage.MTStorage, MTStorage.MTStorage,
ReadOnlyStorage.ReadOnlyStorage, ReadOnlyStorage.ReadOnlyStorage,
# ZEO test mixin classes (in the same order as imported) # ZEO test mixin classes (in the same order as imported)
Cache.StorageWithCache, Cache.StorageWithCache,
Cache.TransUndoStorageWithCache, Cache.TransUndoStorageWithCache,
CommitLockTests.CommitLockTests, CommitLockTests.CommitLockTests,
ThreadTests.ThreadTests, ThreadTests.ThreadTests,
MiscZEOTests # Locally defined (see above) # Locally defined (see above)
MiscZEOTests
): ):
"""Combine tests from various origins in one class.""" """Combine tests from various origins in one class."""
...@@ -141,6 +125,7 @@ class GenericTests( ...@@ -141,6 +125,7 @@ class GenericTests(
if hasattr(ZODB, "__version__"): if hasattr(ZODB, "__version__"):
ReadOnlyStorage.ReadOnlyStorage.checkWriteMethods(self) ReadOnlyStorage.ReadOnlyStorage.checkWriteMethods(self)
class UnixTests(GenericTests): class UnixTests(GenericTests):
"""Add Unix-specific scaffolding to the generic test suite.""" """Add Unix-specific scaffolding to the generic test suite."""
...@@ -162,19 +147,47 @@ class UnixTests(GenericTests): ...@@ -162,19 +147,47 @@ class UnixTests(GenericTests):
self.delStorage() self.delStorage()
def getStorage(self): def getStorage(self):
self.__fs_base = tempfile.mktemp() filename = self.__fs_base = tempfile.mktemp()
return 'FileStorage', (self.__fs_base, '1') # 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): 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.""" """Add Windows-specific scaffolding to the generic test suite."""
def setUp(self): def setUp(self):
zLOG.LOG("testZEO", zLOG.INFO, "setUp() %s" % self.id()) zLOG.LOG("testZEO", zLOG.INFO, "setUp() %s" % self.id())
args = self.getStorageInfo() args = self.getStorage()
name = args[0] name = args[0]
args = args[1] args = args[1]
zeo_addr, self.test_addr, self.test_pid = \ zeo_addr, self.test_addr, self.test_pid = \
...@@ -192,12 +205,6 @@ class WindowsTests(GenericTests): ...@@ -192,12 +205,6 @@ class WindowsTests(GenericTests):
time.sleep(0.5) time.sleep(0.5)
self.delStorage() 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": if os.name == "posix":
test_classes = [UnixTests] test_classes = [UnixTests]
...@@ -206,8 +213,15 @@ elif os.name == "nt": ...@@ -206,8 +213,15 @@ elif os.name == "nt":
else: else:
raise RuntimeError, "unsupported os: %s" % os.name 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 # shutup warnings about mktemp
import warnings import warnings
warnings.filterwarnings("ignore", "mktemp") warnings.filterwarnings("ignore", "mktemp")
...@@ -218,5 +232,6 @@ def test_suite(): ...@@ -218,5 +232,6 @@ def test_suite():
suite.addTest(sub) suite.addTest(sub)
return suite 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