From 5c06ca6a99c892ac4d856002a9b2fd2dcbb64778 Mon Sep 17 00:00:00 2001 From: Nils Philippsen Date: Thu, 20 Aug 2015 10:28:43 +0200 Subject: Python 3: Use the same python interpreter for CGI scripts. Fixes tests.test_cgiapp --- tests/test_cgiapp.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) 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('') -- cgit v1.2.1