Commit 6a66bcd5 authored by Stefan H. Holek's avatar Stefan H. Holek

Fixed two test.py shortcomings:

- test.py lives in ZOPE_HOME for checkouts and ZOPE_HOME/bin for
  installations.
- Comparing abspaths does not fly when symlinks are involved; use
  realpaths instead.
parent 32e7277e
...@@ -21,22 +21,22 @@ $Id: test.py 33303 2005-07-13 22:28:33Z jim $ ...@@ -21,22 +21,22 @@ $Id: test.py 33303 2005-07-13 22:28:33Z jim $
import os.path, sys import os.path, sys
# Remove this directory from path: # Remove script directory from path:
here = os.path.abspath(os.path.dirname(sys.argv[0])) scriptdir = os.path.realpath(os.path.dirname(sys.argv[0]))
sys.path[:] = [p for p in sys.path if os.path.abspath(p) != here] sys.path[:] = [p for p in sys.path if os.path.realpath(p) != scriptdir]
shome = os.environ.get('SOFTWARE_HOME') shome = os.environ.get('SOFTWARE_HOME')
zhome = os.environ.get('ZOPE_HOME') zhome = os.environ.get('ZOPE_HOME')
ihome = os.environ.get('INSTANCE_HOME') ihome = os.environ.get('INSTANCE_HOME')
if zhome: if zhome:
zhome = os.path.abspath(zhome) zhome = os.path.realpath(zhome)
if shome: if shome:
shome = os.path.abspath(shome) shome = os.path.realpath(shome)
else: else:
shome = os.path.join(zhome, 'lib', 'python') shome = os.path.join(zhome, 'lib', 'python')
elif shome: elif shome:
shome = os.path.abspath(shome) shome = os.path.realpath(shome)
zhome = os.path.dirname(os.path.dirname(shome)) zhome = os.path.dirname(os.path.dirname(shome))
elif ihome: elif ihome:
print >> sys.stderr, ''' print >> sys.stderr, '''
...@@ -44,8 +44,13 @@ elif ihome: ...@@ -44,8 +44,13 @@ elif ihome:
must be set must be set
''' '''
else: else:
# No zope home, assume that it is the script directory # No zope home, derive it from script directory:
zhome = os.path.abspath(os.path.dirname(sys.argv[0])) # (test.py lives in either ZOPE_HOME or ZOPE_HOME/bin)
parentdir, lastpart = os.path.split(scriptdir)
if lastpart == 'bin':
zhome = parentdir
else:
zhome = scriptdir
shome = os.path.join(zhome, 'lib', 'python') shome = os.path.join(zhome, 'lib', 'python')
sys.path.insert(0, shome) sys.path.insert(0, shome)
......
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