[Zope-Checkins] SVN: Zope/trunk/ Testing/custom_zodb.py: added
support use a different storage other
Andreas Jung
andreas at andreas-jung.com
Sat Sep 29 04:48:47 EDT 2007
Log message for revision 80357:
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.
Changed:
U Zope/trunk/doc/CHANGES.txt
U Zope/trunk/lib/python/Testing/custom_zodb.py
-=-
Modified: Zope/trunk/doc/CHANGES.txt
===================================================================
--- Zope/trunk/doc/CHANGES.txt 2007-09-28 22:10:07 UTC (rev 80356)
+++ Zope/trunk/doc/CHANGES.txt 2007-09-29 08:48:46 UTC (rev 80357)
@@ -69,6 +69,14 @@
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.
+
- The ZPublisher HTTP request has now both the debug and locale
attributes available, like its Zope 3 counterpart. The debug attribute
was so far limited to code from the zope.* namespace in order to make
Modified: Zope/trunk/lib/python/Testing/custom_zodb.py
===================================================================
--- Zope/trunk/lib/python/Testing/custom_zodb.py 2007-09-28 22:10:07 UTC (rev 80356)
+++ Zope/trunk/lib/python/Testing/custom_zodb.py 2007-09-29 08:48:46 UTC (rev 80357)
@@ -1,4 +1,35 @@
+
+import os
+import logging
import ZODB
-from ZODB.DemoStorage import DemoStorage
-Storage = DemoStorage(quota=(1<<20))
+LOG = logging.getLogger('Testing')
+
+def getStorage():
+
+ get = os.environ.get
+ # Support for running tests against an existing ZEO storage
+ # ATT: better configuration options (ajung, 17.09.2007)
+
+ 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
+ Storage = DemoStorage(quota=(1<<20))
+ LOG.info('Using DemoStorage')
+ return DemoStorage(quota=(1<<20))
+
+Storage = getStorage()
More information about the Zope-Checkins
mailing list