summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_subprocess.py
diff options
context:
space:
mode:
authorAnders Lorentsen <Phaqui@gmail.com>2018-01-30 07:27:28 (GMT)
committerGregory P. Smith <greg@krypto.org>2018-01-30 07:27:28 (GMT)
commitdd42cb71f2cb02f3a32f016137b12a146bc0d0e2 (patch)
treed37a2ca8d77a012cae351b5f8c6654157a706bee /Lib/test/test_subprocess.py
parent14e976e00e65bf343ba0fca016c3c9132a843daf (diff)
downloadcpython-dd42cb71f2cb02f3a32f016137b12a146bc0d0e2.zip
cpython-dd42cb71f2cb02f3a32f016137b12a146bc0d0e2.tar.gz
cpython-dd42cb71f2cb02f3a32f016137b12a146bc0d0e2.tar.bz2
bpo-31961: subprocess now accepts path-like args (GH-4329)
Allow os.PathLike args in subprocess APIs.
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r--Lib/test/test_subprocess.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index eee24bb..858a701 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -1475,6 +1475,37 @@ class RunFuncTestCase(BaseTestCase):
env=newenv)
self.assertEqual(cp.returncode, 33)
+ def test_run_with_pathlike_path(self):
+ # bpo-31961: test run(pathlike_object)
+ class Path:
+ def __fspath__(self):
+ # the name of a command that can be run without
+ # any argumenets that exit fast
+ return 'dir' if mswindows else 'ls'
+
+ path = Path()
+ if mswindows:
+ res = subprocess.run(path, stdout=subprocess.DEVNULL, shell=True)
+ else:
+ res = subprocess.run(path, stdout=subprocess.DEVNULL)
+
+ self.assertEqual(res.returncode, 0)
+
+ def test_run_with_pathlike_path_and_arguments(self):
+ # bpo-31961: test run([pathlike_object, 'additional arguments'])
+ class Path:
+ def __fspath__(self):
+ # the name of a command that can be run without
+ # any argumenets that exits fast
+ return sys.executable
+
+ path = Path()
+
+ args = [path, '-c', 'import sys; sys.exit(57)']
+ res = subprocess.run(args)
+
+ self.assertEqual(res.returncode, 57)
+
def test_capture_output(self):
cp = self.run_python(("import sys;"
"sys.stdout.write('BDFL'); "