[Python-checkins] cpython (merge 3.3 -> default): Merge issue #16115: Add test for check that executable arg to Popen() takes

andrew.svetlov python-checkins at python.org
Fri Oct 5 21:53:25 CEST 2012


http://hg.python.org/cpython/rev/0fcfb6066e17
changeset:   79500:0fcfb6066e17
parent:      79498:5c2aabd7619b
parent:      79499:0df5aeab229f
user:        Andrew Svetlov <andrew.svetlov at gmail.com>
date:        Fri Oct 05 22:53:12 2012 +0300
summary:
  Merge issue #16115: Add test for check that executable arg to Popen() takes precedence over args[0] arg\n                            \n                            Patch by Kushal Das

files:
  Lib/test/test_subprocess.py |  10 ++++++++++
  1 files changed, 10 insertions(+), 0 deletions(-)


diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -299,6 +299,16 @@
         # 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",

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list