summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNils Philippsen <nils@redhat.com>2015-08-20 10:28:43 +0200
committerNils Philippsen <nils@redhat.com>2015-08-20 10:28:43 +0200
commit3b32d2f358eab38c0318475d1d191c68d1dd990d (patch)
treee0b24a3caf2c4586f77ada608f1d54da58047fbd
parenta5ee861c01ec94096dea918d551be596f844291e (diff)
downloadpaste-3b32d2f358eab38c0318475d1d191c68d1dd990d.tar.gz
Python 3: Use the same python interpreter for CGI scripts.
Fixes tests.test_cgiapp
-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('')