Commit b9edf684 authored by Hanno Schlichting's avatar Hanno Schlichting

Removed references to software home.

parent f2285f8f
...@@ -2,14 +2,9 @@ ...@@ -2,14 +2,9 @@
ZTC makes the following assumptions about its environment: ZTC makes the following assumptions about its environment:
a) The 'ZopeTestCase' package is installed in the Zope "trunk" inside the a) The 'ZopeTestCase' package is installed in the Zope "trunk" inside the
'Testing' module, which means: SOFTWARE_HOME/Testing/ZopeTestCase. 'Testing' module.
b) A 'Products' directory exists inside SOFTWARE_HOME and INSTANCE_HOME. b) The somewhat weak assumption is that ZTC can walk up the directory tree from
c) The tests (the 'tests' subdirectories) are located either below a
SOFTWARE_HOME or INSTANCE_HOME, typically in Products/MyCoolProduct/tests.
d) The somewhat weak assumption is that ZTC can walk up the directory tree from
'tests', and find a 'Products' directory. This is how INSTANCE_HOME 'tests', and find a 'Products' directory. This is how INSTANCE_HOME
detection works. It regrettably fails on some filesystems when symbolic detection works. It regrettably fails on some filesystems when symbolic
links are involved (a solution is detailed below, so hang on). links are involved (a solution is detailed below, so hang on).
...@@ -24,8 +19,7 @@ The non-trivial part is that INSTANCE_HOME has two distinct purposes: ...@@ -24,8 +19,7 @@ The non-trivial part is that INSTANCE_HOME has two distinct purposes:
ZTC attempts to resolve this by detecting an INSTANCE_HOME for 1) but leaving ZTC attempts to resolve this by detecting an INSTANCE_HOME for 1) but leaving
the actual environment variable untouched so 2) works by still pointing into the actual environment variable untouched.
SOFTWARE_HOME/Testing.
As soon as I allow you to set INSTANCE_HOME yourself, I lose the ability to As soon as I allow you to set INSTANCE_HOME yourself, I lose the ability to
distinguish whether you mean 1) or 2) or both. distinguish whether you mean 1) or 2) or both.
......
...@@ -43,27 +43,9 @@ ZopeTestCase Readme ...@@ -43,27 +43,9 @@ ZopeTestCase Readme
Note that there is a skeleton test suite named 'testSkeleton.py' that you Note that there is a skeleton test suite named 'testSkeleton.py' that you
may copy into your 'tests' directory and take it from there. may copy into your 'tests' directory and take it from there.
Note also that when the tests are run in an INSTANCE_HOME installation of
Zope, you must set the SOFTWARE_HOME environment variable for the 'Testing'
and 'ZopeTestCase' packages to be found.
See the sample tests in the 'ZopeTestCase' directory for details on writing See the sample tests in the 'ZopeTestCase' directory for details on writing
your own tests. your own tests.
framework.py
1. Uses SOFTWARE_HOME (if set) to locate the Testing package.
2. Detects and handles INSTANCE_HOME installations of Zope. Please
see ENVIRONMENT.txt for the assumptions ZTC makes about its
environment.
3. Supports setting up a ZODB from a 'custom_zodb.py' file in
the 'tests' directory.
4. Allows to connect to a running ZEO server by setting the
ZEO_INSTANCE_HOME environment variable.
testrunner.py testrunner.py
Alternatively, you may use Zope's testrunner utility to run your tests Alternatively, you may use Zope's testrunner utility to run your tests
...@@ -71,8 +53,7 @@ testrunner.py ...@@ -71,8 +53,7 @@ testrunner.py
installation). If you do so, you will have to define a 'test_suite' method installation). If you do so, you will have to define a 'test_suite' method
in your modules (see examples). in your modules (see examples).
There is no need to set SOFTWARE_HOME when using the testrunner but you may You may have to provide the -i flag when testing in an INSTANCE_HOME setup.
have to provide the -i flag when testing in an INSTANCE_HOME setup.
Example: 'python /path/to/Zope/utilities/testrunner.py -q -i -a' Example: 'python /path/to/Zope/utilities/testrunner.py -q -i -a'
......
...@@ -5,7 +5,6 @@ When the skeleton test is run by typing 'python testSkeleton.py', it ...@@ -5,7 +5,6 @@ When the skeleton test is run by typing 'python testSkeleton.py', it
1. includes file framework.py 1. includes file framework.py
1.1 locates and imports the Testing package by means of 1.1 locates and imports the Testing package by means of
- SOFTWARE_HOME environment variable
- auto-detection - auto-detection
1.2 locates and includes file ztc_common.py 1.2 locates and includes file ztc_common.py
......
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""ZopeTestCase framework
COPY THIS FILE TO YOUR 'tests' DIRECTORY.
This version of framework.py will use the SOFTWARE_HOME
environment variable to locate Zope and the Testing package.
If the tests are run in an INSTANCE_HOME installation of Zope,
Products.__path__ and sys.path with be adjusted to include the
instance's Products and lib/python directories respectively.
If you explicitly set INSTANCE_HOME prior to running the tests,
auto-detection is disabled and the specified path will be used
instead.
If the 'tests' directory contains a custom_zodb.py file, INSTANCE_HOME
will be adjusted to use it.
If you set the ZEO_INSTANCE_HOME environment variable a ZEO setup
is assumed, and you can attach to a running ZEO server (via the
instance's custom_zodb.py).
The following code should be at the top of every test module:
import os, sys
if __name__ == '__main__':
execfile(os.path.join(sys.path[0], 'framework.py'))
...and the following at the bottom:
if __name__ == '__main__':
framework()
$Id:$
"""
__version__ = '0.2.4'
# Save start state
#
__SOFTWARE_HOME = os.environ.get('SOFTWARE_HOME', '')
__INSTANCE_HOME = os.environ.get('INSTANCE_HOME', '')
if __SOFTWARE_HOME.endswith(os.sep):
__SOFTWARE_HOME = os.path.dirname(__SOFTWARE_HOME)
if __INSTANCE_HOME.endswith(os.sep):
__INSTANCE_HOME = os.path.dirname(__INSTANCE_HOME)
# Find and import the Testing package
#
if not sys.modules.has_key('Testing'):
p0 = sys.path[0]
if p0 and __name__ == '__main__':
os.chdir(p0)
p0 = ''
s = __SOFTWARE_HOME
p = d = s and s or os.getcwd()
while d:
if os.path.isdir(os.path.join(p, 'Testing')):
zope_home = os.path.dirname(os.path.dirname(p))
sys.path[:1] = [p0, p, zope_home]
break
p, d = s and ('','') or os.path.split(p)
else:
print 'Unable to locate Testing package.',
print 'You might need to set SOFTWARE_HOME.'
sys.exit(1)
import Testing, unittest
execfile(os.path.join(os.path.dirname(Testing.__file__), 'common.py'))
# Include ZopeTestCase support
#
if 1: # Create a new scope
p = os.path.join(os.path.dirname(Testing.__file__), 'ZopeTestCase')
if not os.path.isdir(p):
print 'Unable to locate ZopeTestCase package.',
print 'You might need to install ZopeTestCase.'
sys.exit(1)
ztc_common = 'ztc_common.py'
ztc_common_global = os.path.join(p, ztc_common)
f = 0
if os.path.exists(ztc_common_global):
execfile(ztc_common_global)
f = 1
if os.path.exists(ztc_common):
execfile(ztc_common)
f = 1
if not f:
print 'Unable to locate %s.' % ztc_common
sys.exit(1)
# Debug
#
print 'SOFTWARE_HOME: %s' % os.environ.get('SOFTWARE_HOME', 'Not set')
print 'INSTANCE_HOME: %s' % os.environ.get('INSTANCE_HOME', 'Not set')
sys.stdout.flush()
##############################################################################
#
# Copyright (c) 2005 Zope Corporation and Contributors. All Rights Reserved.
#
# This software is subject to the provisions of the Zope Public License,
# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
# FOR A PARTICULAR PURPOSE.
#
##############################################################################
"""ZopeTestCase framework
COPY THIS FILE TO YOUR 'tests' DIRECTORY.
This version of framework.py will use the SOFTWARE_HOME
environment variable to locate Zope and the Testing package.
If the tests are run in an INSTANCE_HOME installation of Zope,
Products.__path__ and sys.path with be adjusted to include the
instance's Products and lib/python directories respectively.
If you explicitly set INSTANCE_HOME prior to running the tests,
auto-detection is disabled and the specified path will be used
instead.
If the 'tests' directory contains a custom_zodb.py file, INSTANCE_HOME
will be adjusted to use it.
If you set the ZEO_INSTANCE_HOME environment variable a ZEO setup
is assumed, and you can attach to a running ZEO server (via the
instance's custom_zodb.py).
The following code should be at the top of every test module:
import os, sys
if __name__ == '__main__':
execfile(os.path.join(sys.path[0], 'framework.py'))
...and the following at the bottom:
if __name__ == '__main__':
framework()
$Id:$
"""
__version__ = '0.2.4'
# Save start state
#
__SOFTWARE_HOME = os.environ.get('SOFTWARE_HOME', '')
__INSTANCE_HOME = os.environ.get('INSTANCE_HOME', '')
if __SOFTWARE_HOME.endswith(os.sep):
__SOFTWARE_HOME = os.path.dirname(__SOFTWARE_HOME)
if __INSTANCE_HOME.endswith(os.sep):
__INSTANCE_HOME = os.path.dirname(__INSTANCE_HOME)
# Find and import the Testing package
#
if not sys.modules.has_key('Testing'):
p0 = sys.path[0]
if p0 and __name__ == '__main__':
os.chdir(p0)
p0 = ''
s = __SOFTWARE_HOME
p = d = s and s or os.getcwd()
while d:
if os.path.isdir(os.path.join(p, 'Testing')):
zope_home = os.path.dirname(os.path.dirname(p))
sys.path[:1] = [p0, p, zope_home]
break
p, d = s and ('','') or os.path.split(p)
else:
print 'Unable to locate Testing package.',
print 'You might need to set SOFTWARE_HOME.'
sys.exit(1)
import Testing, unittest
execfile(os.path.join(os.path.dirname(Testing.__file__), 'common.py'))
# Include ZopeTestCase support
#
if 1: # Create a new scope
p = os.path.join(os.path.dirname(Testing.__file__), 'ZopeTestCase')
if not os.path.isdir(p):
print 'Unable to locate ZopeTestCase package.',
print 'You might need to install ZopeTestCase.'
sys.exit(1)
ztc_common = 'ztc_common.py'
ztc_common_global = os.path.join(p, ztc_common)
f = 0
if os.path.exists(ztc_common_global):
execfile(ztc_common_global)
f = 1
if os.path.exists(ztc_common):
execfile(ztc_common)
f = 1
if not f:
print 'Unable to locate %s.' % ztc_common
sys.exit(1)
# Debug
#
print 'SOFTWARE_HOME: %s' % os.environ.get('SOFTWARE_HOME', 'Not set')
print 'INSTANCE_HOME: %s' % os.environ.get('INSTANCE_HOME', 'Not set')
sys.stdout.flush()
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