Commit 5331a781 authored by Andreas Zeidler's avatar Andreas Zeidler

backport support for testing against storages other than `DemoStorage`...

backport support for testing against storages other than `DemoStorage` (r80357:80358) from Zope 2.11
parent 92fd3f0f
......@@ -6,6 +6,16 @@ Zope Changes
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
......
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()
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