]> granicus.if.org Git - python/commitdiff
Issue #28662: Catch PermissionError in tests when spawning a non existent program
authorXavier de Gaye <xdegaye@users.sourceforge.net>
Mon, 14 Nov 2016 16:14:42 +0000 (17:14 +0100)
committerXavier de Gaye <xdegaye@users.sourceforge.net>
Mon, 14 Nov 2016 16:14:42 +0000 (17:14 +0100)
Lib/test/test_dtrace.py
Lib/test/test_shutil.py
Lib/test/test_subprocess.py

index ca239b321b05d902f09b031d5a72d280a99b1d45..47a501018a32b1186932e5c87e71b68e3af98298 100644 (file)
@@ -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(
index d93efb8867ac703d27f0684337867daa430eca74..af5f00fdf0d7402bb04c36d6abb6847bf055f957 100644 (file)
@@ -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
 
index 2d9239c75905efa1f58bdfe8f60419261993ad21..73da1956eaaf77bdee87b8e453090ca08e067e11 100644 (file)
@@ -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: