Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 220e869

Browse files
committed
Merge issue #16115: Add test for check that executable arg to Popen() takes precedence over args[0] arg\n \n Patch by Kushal Das
2 parents 64478ac + 1a53c0c commit 220e869

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

Lib/test/test_subprocess.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,16 @@ def test_executable_without_cwd(self):
299299
# argument. For test runs in the build directory, see #7774.
300300
self._assert_cwd('', "somethingyoudonthave", executable=sys.executable)
301301

302+
def test_executable_precedence(self):
303+
# To the precedence of executable argument over args[0]
304+
# For a normal installation, it should work without 'cwd'
305+
# argument. For test runs in the build directory, see #7774.
306+
python_dir = os.path.dirname(os.path.realpath(sys.executable))
307+
p = subprocess.Popen(["nonexistent","-c",'import sys; sys.exit(42)'],
308+
executable=sys.executable, cwd=python_dir)
309+
p.wait()
310+
self.assertEqual(p.returncode, 42)
311+
302312
def test_stdin_pipe(self):
303313
# stdin redirection
304314
p = subprocess.Popen([sys.executable, "-c",

0 commit comments

Comments
 (0)