Kaydet (Commit) fae0512e authored tarafından Miss Islington (bot)'s avatar Miss Islington (bot) Kaydeden (comit) Victor Stinner

[3.6] bpo-31178: Mock os.waitpid() in test_subprocess (GH-3896) (#3897)

Fix test_exception_errpipe_bad_data() and
test_exception_errpipe_normal() of test_subprocess: mock os.waitpid()
to avoid calling the real os.waitpid(0, 0) which is an unexpected
side effect of the test.
(cherry picked from commit 11045c9d)
üst de5427a8
...@@ -1568,6 +1568,8 @@ class POSIXProcessTestCase(BaseTestCase): ...@@ -1568,6 +1568,8 @@ class POSIXProcessTestCase(BaseTestCase):
fork_exec.side_effect = proper_error fork_exec.side_effect = proper_error
with mock.patch("subprocess.os.waitpid",
side_effect=ChildProcessError):
with self.assertRaises(IsADirectoryError): with self.assertRaises(IsADirectoryError):
self.PopenNoDestructor(["non_existent_command"]) self.PopenNoDestructor(["non_existent_command"])
...@@ -1586,6 +1588,8 @@ class POSIXProcessTestCase(BaseTestCase): ...@@ -1586,6 +1588,8 @@ class POSIXProcessTestCase(BaseTestCase):
fork_exec.side_effect = bad_error fork_exec.side_effect = bad_error
with mock.patch("subprocess.os.waitpid",
side_effect=ChildProcessError):
with self.assertRaises(subprocess.SubprocessError) as e: with self.assertRaises(subprocess.SubprocessError) as e:
self.PopenNoDestructor(["non_existent_command"]) self.PopenNoDestructor(["non_existent_command"])
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment