]> granicus.if.org Git - python/commitdiff
Issue #16115: Add test for check that executable arg to Popen() takes precedence...
authorAndrew Svetlov <andrew.svetlov@gmail.com>
Fri, 5 Oct 2012 19:52:15 +0000 (22:52 +0300)
committerAndrew Svetlov <andrew.svetlov@gmail.com>
Fri, 5 Oct 2012 19:52:15 +0000 (22:52 +0300)
Lib/test/test_subprocess.py

index 476d22981a23c645ec5c9f4d46772ea33d86dc58..6fc61088b8f9d2c63c4b790deef91e11405d7b71 100644 (file)
@@ -299,6 +299,16 @@ class ProcessTestCase(BaseTestCase):
         # argument.  For test runs in the build directory, see #7774.
         self._assert_cwd('', "somethingyoudonthave", executable=sys.executable)
 
+    def test_executable_precedence(self):
+        # To the precedence of executable argument over args[0]
+        # For a normal installation, it should work without 'cwd'
+        # argument. For test runs in the build directory, see #7774.
+        python_dir = os.path.dirname(os.path.realpath(sys.executable))
+        p = subprocess.Popen(["nonexistent","-c",'import sys; sys.exit(42)'],
+                            executable=sys.executable, cwd=python_dir)
+        p.wait()
+        self.assertEqual(p.returncode, 42)
+
     def test_stdin_pipe(self):
         # stdin redirection
         p = subprocess.Popen([sys.executable, "-c",