summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorR. Tyler Ballance <tyler@monkeypox.org>2010-03-21 20:29:16 -0700
committerR. Tyler Ballance <tyler@monkeypox.org>2010-03-21 20:29:16 -0700
commit8724436c90babf5a9e45580858749ad3050d0db3 (patch)
tree1177073d76202e76f0641402da66afa59682b205
parent7ab7f51887f448e808dd401e1c89dd6c61f604ad (diff)
downloadpython-cheetah-8724436c90babf5a9e45580858749ad3050d0db3.tar.gz
Properly generate a PYTHONPATH and locate the cheetah executable for CheetahWrapper tests
On FreeBSD particularly, the tempfile.mktemp() heavily sandboxes the process into /tmp/ somewhere. Finding absolute paths to the cheetah process and the Cheetah/ directory is necessary to properly run the tests
-rw-r--r--cheetah/Tests/CheetahWrapper.py18
1 files changed, 12 insertions, 6 deletions
diff --git a/cheetah/Tests/CheetahWrapper.py b/cheetah/Tests/CheetahWrapper.py
index 1097aa0..cabe651 100644
--- a/cheetah/Tests/CheetahWrapper.py
+++ b/cheetah/Tests/CheetahWrapper.py
@@ -63,6 +63,12 @@ class CFBase(unittest.TestCase):
"""Create the top-level directories, subdirectories and .tmpl
files.
"""
+ self.cmd = self.locate_cheetah('cheetah')
+ pythonPath = os.getcwd()
+ if not os.environ.get('PYTHONPATH'):
+ os.environ['PYTHONPATH'] = pythonPath
+ else:
+ os.environ['PYTHONPATH'] = '%s:%s' % (os.environ['PYTHONPATH'], pythonPath)
I = self.inform
# Step 1: Create the scratch directory and chdir into it.
self.scratchDir = scratchDir = tempfile.mktemp()
@@ -79,7 +85,6 @@ class CFBase(unittest.TestCase):
f = open(fil, 'w')
f.write("Hello, world!\n")
f.close()
-
def tearDown(self):
os.chdir(self.origCwd)
@@ -157,17 +162,18 @@ Found %(result)r"""
msg = "backup file exists in spite of --nobackup: %s" % path
self.failIf(exists, msg)
- def locate_command(self, cmd):
+ def locate_cheetah(self, cmd):
paths = os.getenv('PATH')
if not paths:
return cmd
parts = cmd.split(' ')
paths = paths.split(':')
for p in paths:
- p = p + os.path.sep + parts[0]
+ p = os.path.join(p, cmd)
+ p = os.path.abspath(p)
if os.path.isfile(p):
- return ' '.join([p] + parts[1:])
- return ' '.join(parts)
+ return p
+ return cmd
def assertWin32Subprocess(self, cmd):
_in, _out = os.popen4(cmd)
@@ -179,7 +185,7 @@ Found %(result)r"""
return rc, output
def assertPosixSubprocess(self, cmd):
- cmd = self.locate_command(cmd)
+ cmd = cmd.replace('cheetah', self.cmd)
process = Popen4(cmd, env=os.environ)
process.tochild.close()
output = process.fromchild.read()