summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_subprocess.py
diff options
context:
space:
mode:
authorGregory P. Smith <greg@krypto.org>2017-09-04 21:23:23 (GMT)
committerGitHub <noreply@github.com>2017-09-04 21:23:23 (GMT)
commit1dba3789e335f06e3b01cdc84070f2e828c9b861 (patch)
tree02f9ea9136c807f1e6a120637aae3047d509409b /Lib/test/test_subprocess.py
parent703fdb837abb8e6c4df4e7070dc266383e9a7bd7 (diff)
downloadcpython-1dba3789e335f06e3b01cdc84070f2e828c9b861.zip
cpython-1dba3789e335f06e3b01cdc84070f2e828c9b861.tar.gz
cpython-1dba3789e335f06e3b01cdc84070f2e828c9b861.tar.bz2
bpo-22536 [3.6] Set filename in FileNotFoundError (#3305)
* [3.6] bpo-22536: Set the filename in FileNotFoundError. (GH-3194) Have the subprocess module set the filename in the FileNotFoundError exception raised on POSIX systems when the executable or cwd are missing. (cherry picked from commit 8621bb5d93239316f97281826461b85072ff6db7) * bpo-22536 [3.6] (GH-3202) skip non-windows tests.
Diffstat (limited to 'Lib/test/test_subprocess.py')
-rw-r--r--Lib/test/test_subprocess.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
index ccdd323..83abe9d 100644
--- a/Lib/test/test_subprocess.py
+++ b/Lib/test/test_subprocess.py
@@ -1375,6 +1375,18 @@ class ProcessTestCase(BaseTestCase):
fds_after_exception = os.listdir(fd_directory)
self.assertEqual(fds_before_popen, fds_after_exception)
+ @unittest.skipIf(mswindows, "behavior currently not supported on Windows")
+ def test_file_not_found_includes_filename(self):
+ with self.assertRaises(FileNotFoundError) as c:
+ subprocess.call(['/opt/nonexistent_binary', 'with', 'some', 'args'])
+ self.assertEqual(c.exception.filename, '/opt/nonexistent_binary')
+
+ @unittest.skipIf(mswindows, "behavior currently not supported on Windows")
+ def test_file_not_found_with_bad_cwd(self):
+ with self.assertRaises(FileNotFoundError) as c:
+ subprocess.Popen(['exit', '0'], cwd='/some/nonexistent/directory')
+ self.assertEqual(c.exception.filename, '/some/nonexistent/directory')
+
class RunFuncTestCase(BaseTestCase):
def run_python(self, code, **kwargs):