bpo-31178: Mock os.waitpid() in test_subprocess (#3896)

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.
This commit is contained in:
Victor Stinner 2017-10-05 06:32:53 -07:00 committed by GitHub
parent c1c47c166b
commit 11045c9d8a
1 changed files with 8 additions and 4 deletions

View File

@ -1559,6 +1559,8 @@ class POSIXProcessTestCase(BaseTestCase):
fork_exec.side_effect = proper_error
with mock.patch("subprocess.os.waitpid",
side_effect=ChildProcessError):
with self.assertRaises(IsADirectoryError):
self.PopenNoDestructor(["non_existent_command"])
@ -1577,6 +1579,8 @@ class POSIXProcessTestCase(BaseTestCase):
fork_exec.side_effect = bad_error
with mock.patch("subprocess.os.waitpid",
side_effect=ChildProcessError):
with self.assertRaises(subprocess.SubprocessError) as e:
self.PopenNoDestructor(["non_existent_command"])