[Zope-Checkins] SVN: Zope/branches/2.10/ backport support for testing against storages other than `DemoStorage` (r80357:80358) from Zope 2.11
Andreas Zeidler
az at zitc.de
Sat Oct 31 07:27:55 EDT 2009
Log message for revision 105407:
backport support for testing against storages other than `DemoStorage` (r80357:80358) from Zope 2.11
Changed:
U Zope/branches/2.10/doc/CHANGES.txt
U Zope/branches/2.10/lib/python/Testing/custom_zodb.py
-=-
Modified: Zope/branches/2.10/doc/CHANGES.txt
===================================================================
--- Zope/branches/2.10/doc/CHANGES.txt 2009-10-31 11:04:38 UTC (rev 105406)
+++ Zope/branches/2.10/doc/CHANGES.txt 2009-10-31 11:27:55 UTC (rev 105407)
@@ -6,6 +6,16 @@
Zope 2.10.10 (Unreleased)
+ Features added
+
+ - Testing/custom_zodb.py: added support use a different storage other
+ than DemoStorage. A dedicated FileStorage can be mount by setting the
+ $TEST_FILESTORAGE environment variable to a custom Data.fs file. A
+ ZEO server can be configured using the $TEST_ZEO_HOST and
+ $TEST_ZEO_PORT environment variables. This new functionality allows us
+ to use the standard Zope testrunner for writing and running tests
+ against existing Zope installations.
+
Bugs fixed
- LP #360761 (backported from Acquisition trunk): fix iteration proxy
Modified: Zope/branches/2.10/lib/python/Testing/custom_zodb.py
===================================================================
--- Zope/branches/2.10/lib/python/Testing/custom_zodb.py 2009-10-31 11:04:38 UTC (rev 105406)
+++ Zope/branches/2.10/lib/python/Testing/custom_zodb.py 2009-10-31 11:27:55 UTC (rev 105407)
@@ -1,4 +1,36 @@
+
+import os
+import logging
import ZODB
-from ZODB.DemoStorage import DemoStorage
-Storage = DemoStorage(quota=(1<<20))
+LOG = logging.getLogger('Testing')
+
+def getStorage():
+ """ Return a storage instance for running ZopeTestCase based
+ tests. By default a DemoStorage is used. Setting
+ $TEST_ZEO_HOST/TEST_ZEO_PORT environment variables allows you
+ to use a ZEO server instead. A file storage can be configured
+ by settting the $TEST_FILESTORAGE environment variable.
+ """
+
+ get = os.environ.get
+
+ if os.environ.has_key('TEST_ZEO_HOST') and os.environ.has_key('TEST_ZEO_PORT'):
+ from ZEO.ClientStorage import ClientStorage
+ zeo_host = get('TEST_ZEO_HOST')
+ zeo_port = int(get('TEST_ZEO_PORT'))
+ LOG.info('Using ZEO server (%s:%d)' % (zeo_host, zeo_port))
+ return ClientStorage((zeo_host, zeo_port))
+
+ elif os.environ.has_key('TEST_FILESTORAGE'):
+ import ZODB.FileStorage
+ datafs = get('TEST_FILESTORAGE')
+ LOG.info('Using Filestorage at (%s)' % datafs)
+ return ZODB.FileStorage.FileStorage(datafs)
+
+ else:
+ from ZODB.DemoStorage import DemoStorage
+ LOG.info('Using DemoStorage')
+ return DemoStorage(quota=(1<<20))
+
+Storage = getStorage()
More information about the Zope-Checkins
mailing list