Blame SOURCES/00277-fix-test-subprocess-hanging-tests.patch

2a6dbc
From 54849962eacc38f4e6c6f8a72ae258b3e7c2ecd5 Mon Sep 17 00:00:00 2001
2a6dbc
From: Victor Stinner <victor.stinner@gmail.com>
2a6dbc
Date: Thu, 5 Oct 2017 15:05:30 +0200
2a6dbc
Subject: [PATCH] bpo-31178: Mock os.waitpid() in test_subprocess
2a6dbc
2a6dbc
Fix test_exception_errpipe_bad_data() and
2a6dbc
test_exception_errpipe_normal() of test_subprocess: mock os.waitpid()
2a6dbc
to avoid calling the real os.waitpid(0, 0) which is an unexpected
2a6dbc
side effect of the test.
2a6dbc
---
2a6dbc
 Lib/test/test_subprocess.py | 12 ++++++++----
2a6dbc
 1 file changed, 8 insertions(+), 4 deletions(-)
2a6dbc
2a6dbc
diff --git a/Lib/test/test_subprocess.py b/Lib/test/test_subprocess.py
2a6dbc
index 00dc37bc2c7..3ba5c028517 100644
2a6dbc
--- a/Lib/test/test_subprocess.py
2a6dbc
+++ b/Lib/test/test_subprocess.py
2a6dbc
@@ -1559,8 +1559,10 @@ def proper_error(*args):
2a6dbc
 
2a6dbc
         fork_exec.side_effect = proper_error
2a6dbc
 
2a6dbc
-        with self.assertRaises(IsADirectoryError):
2a6dbc
-            self.PopenNoDestructor(["non_existent_command"])
2a6dbc
+        with mock.patch("subprocess.os.waitpid",
2a6dbc
+                        side_effect=ChildProcessError):
2a6dbc
+            with self.assertRaises(IsADirectoryError):
2a6dbc
+                self.PopenNoDestructor(["non_existent_command"])
2a6dbc
 
2a6dbc
     @mock.patch("subprocess._posixsubprocess.fork_exec")
2a6dbc
     def test_exception_errpipe_bad_data(self, fork_exec):
2a6dbc
@@ -1577,8 +1579,10 @@ def bad_error(*args):
2a6dbc
 
2a6dbc
         fork_exec.side_effect = bad_error
2a6dbc
 
2a6dbc
-        with self.assertRaises(subprocess.SubprocessError) as e:
2a6dbc
-            self.PopenNoDestructor(["non_existent_command"])
2a6dbc
+        with mock.patch("subprocess.os.waitpid",
2a6dbc
+                        side_effect=ChildProcessError):
2a6dbc
+            with self.assertRaises(subprocess.SubprocessError) as e:
2a6dbc
+                self.PopenNoDestructor(["non_existent_command"])
2a6dbc
 
2a6dbc
         self.assertIn(repr(error_data), str(e.exception))
2a6dbc