Commit 7a2792d8 authored by Shane Hathaway's avatar Shane Hathaway

These changes make it so you can safely "import Zope" in a unit test. You

still shouldn't import Zope in unit tests, but most of the existing CMF tests
depend on importing Zope and there was a hidden exception occurring anyway.
(OFS.Application.initialize() was failing.)
parent f70cca83
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
""" """
Set up testing environment Set up testing environment
$Id: __init__.py,v 1.4 2001/11/28 15:51:17 matt Exp $ $Id: __init__.py,v 1.5 2002/01/11 17:07:32 shane Exp $
""" """
import os import os
...@@ -26,7 +26,8 @@ os.environ['INSTANCE_HOME'] = INSTANCE_HOME = pdir(__file__) ...@@ -26,7 +26,8 @@ os.environ['INSTANCE_HOME'] = INSTANCE_HOME = pdir(__file__)
# Set the SOFTWARE_HOME to the directory containing the Testing package # Set the SOFTWARE_HOME to the directory containing the Testing package
os.environ['SOFTWARE_HOME'] = SOFTWARE_HOME = pdir(INSTANCE_HOME) os.environ['SOFTWARE_HOME'] = SOFTWARE_HOME = pdir(INSTANCE_HOME)
# Prevent useless initialization by pretending to be a ZEO client # Note: we don't set os.environ['ZEO_CLIENT'] anymore because we
os.environ['ZEO_CLIENT'] = '1' # really do need all the products to be initialized. Some tests
# use the product registry.
This directory may be used by some tests (such as the ZEO tests).
...@@ -311,6 +311,13 @@ def main(args): ...@@ -311,6 +311,13 @@ def main(args):
sys.path.insert( 0, sw_home ) sys.path.insert( 0, sw_home )
os.environ['SOFTWARE_HOME'] = sw_home os.environ['SOFTWARE_HOME'] = sw_home
try:
# Try to set up the testing environment (esp. INSTANCE_HOME,
# so we use the right custom_zodb.py.)
import Testing
except ImportError:
pass
if test_all: if test_all:
testrunner.runAllTests() testrunner.runAllTests()
elif pathname: elif pathname:
......
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