[Test] Allow 'runCythonTests' to be called from any working directory

This commit is contained in:
Ray Speth 2014-03-24 04:03:35 +00:00
parent de8a19ed0f
commit 1fd98a2f08
2 changed files with 11 additions and 6 deletions

View file

@ -93,8 +93,7 @@ def addPythonTest(testname, subdir, script, interpreter, outfile,
print k,v
environ[k] = v
code = subprocess.call([env.subst(interpreter), source[0].abspath] + args.split(),
env=environ,
cwd=workDir)
env=environ)
if not code:
# Test was successful
open(target[0].path, 'w').write(time.asctime()+'\n')

View file

@ -13,11 +13,17 @@ from __future__ import print_function
import sys
import os
cantera_root = os.getcwd().split(os.sep)[:-2]
if sys.version_info[0] == 3:
sys.path.insert(0, os.sep.join(cantera_root + ['build', 'python3']))
cantera_root = os.path.relpath(__file__).split(os.sep)[:-1] + ['..', '..']
py_version = 'python3' if sys.version_info[0] == 3 else 'python2'
module_path = os.path.abspath(os.sep.join(cantera_root + ['build', py_version]))
if 'PYTHONPATH' in os.environ:
os.environ['PYTHONPATH'] = module_path + os.path.pathsep + os.environ['PYTHONPATH']
else:
sys.path.insert(0, os.sep.join(cantera_root + ['build', 'python2']))
os.environ['PYTHONPATH'] = module_path
sys.path.insert(0, module_path)
os.chdir(os.sep.join(cantera_root + ['test', 'work']))
from cantera.test.utilities import unittest
import cantera