summaryrefslogtreecommitdiff
path: root/tests/test_cgiapp.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test_cgiapp.py')
-rw-r--r--tests/test_cgiapp.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/test_cgiapp.py b/tests/test_cgiapp.py
index 12cb2be..900e83e 100644
--- a/tests/test_cgiapp.py
+++ b/tests/test_cgiapp.py
@@ -8,6 +8,29 @@ data_dir = os.path.join(os.path.dirname(__file__), 'cgiapp_data')
# these CGI scripts can't work on Windows or Jython
if sys.platform != 'win32' and not sys.platform.startswith('java'):
+
+ # Ensure the CGI scripts are called with the same python interpreter. Put a
+ # symlink to the interpreter executable into the path...
+ def setup_module():
+ global oldpath, pyexelink
+ oldpath = os.environ.get('PATH', None)
+ os.environ['PATH'] = data_dir + os.path.pathsep + oldpath
+ pyexelink = os.path.join(data_dir, "python")
+ try:
+ os.unlink(pyexelink)
+ except OSError:
+ pass
+ os.symlink(sys.executable, pyexelink)
+
+ # ... and clean up again.
+ def teardown_module():
+ global oldpath, pyexelink
+ os.unlink(pyexelink)
+ if oldpath is not None:
+ os.environ['PATH'] = oldpath
+ else:
+ del os.environ['PATH']
+
def test_ok():
app = TestApp(CGIApplication({}, script='ok.cgi', path=[data_dir]))
res = app.get('')