From: Xavier de Gaye Date: Mon, 14 Nov 2016 16:14:42 +0000 (+0100) Subject: Issue #28662: Catch PermissionError in tests when spawning a non existent program X-Git-Tag: v3.6.0b4~85 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=38c8b7d2922c20010930eedacdccf61fb2246761;p=thirdparty%2FPython%2Fcpython.git Issue #28662: Catch PermissionError in tests when spawning a non existent program --- diff --git a/Lib/test/test_dtrace.py b/Lib/test/test_dtrace.py index ca239b321b05..47a501018a32 100644 --- a/Lib/test/test_dtrace.py +++ b/Lib/test/test_dtrace.py @@ -79,7 +79,7 @@ class TraceBackend: try: output = self.trace(abspath("assert_usable" + self.EXTENSION)) output = output.strip() - except FileNotFoundError as fnfe: + except (FileNotFoundError, PermissionError) as fnfe: output = str(fnfe) if output != "probe: success": raise unittest.SkipTest( diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py index d93efb8867ac..af5f00fdf0d7 100644 --- a/Lib/test/test_shutil.py +++ b/Lib/test/test_shutil.py @@ -1869,7 +1869,8 @@ class TermsizeTests(unittest.TestCase): """ try: size = subprocess.check_output(['stty', 'size']).decode().split() - except (FileNotFoundError, subprocess.CalledProcessError): + except (FileNotFoundError, PermissionError, + subprocess.CalledProcessError): self.skipTest("stty invocation failed") expected = (int(size[1]), int(size[0])) # reversed order diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py index 2d9239c75905..73da1956eaaf 100644 --- a/Lib/test/test_subprocess.py +++ b/Lib/test/test_subprocess.py @@ -293,7 +293,8 @@ class ProcessTestCase(BaseTestCase): # Verify first that the call succeeds without the executable arg. pre_args = [sys.executable, "-c"] self._assert_python(pre_args) - self.assertRaises(FileNotFoundError, self._assert_python, pre_args, + self.assertRaises((FileNotFoundError, PermissionError), + self._assert_python, pre_args, executable="doesnotexist") @unittest.skipIf(mswindows, "executable argument replaces shell") @@ -2753,7 +2754,7 @@ class ContextManagerTests(BaseTestCase): self.assertEqual(proc.returncode, 1) def test_invalid_args(self): - with self.assertRaises(FileNotFoundError) as c: + with self.assertRaises((FileNotFoundError, PermissionError)) as c: with subprocess.Popen(['nonexisting_i_hope'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) as proc: