summaryrefslogtreecommitdiffstats
path: root/Lib/test/_test_multiprocessing.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/_test_multiprocessing.py')
-rw-r--r--Lib/test/_test_multiprocessing.py31
1 files changed, 29 insertions, 2 deletions
diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
index 1e497a5..940fe58 100644
--- a/Lib/test/_test_multiprocessing.py
+++ b/Lib/test/_test_multiprocessing.py
@@ -584,10 +584,19 @@ class _TestProcess(BaseTestCase):
self.assertTrue(evt.is_set())
@classmethod
- def _test_error_on_stdio_flush(self, evt):
+ def _test_error_on_stdio_flush(self, evt, break_std_streams={}):
+ for stream_name, action in break_std_streams.items():
+ if action == 'close':
+ stream = io.StringIO()
+ stream.close()
+ else:
+ assert action == 'remove'
+ stream = None
+ setattr(sys, stream_name, None)
evt.set()
- def test_error_on_stdio_flush(self):
+ def test_error_on_stdio_flush_1(self):
+ # Check that Process works with broken standard streams
streams = [io.StringIO(), None]
streams[0].close()
for stream_name in ('stdout', 'stderr'):
@@ -601,6 +610,24 @@ class _TestProcess(BaseTestCase):
proc.start()
proc.join()
self.assertTrue(evt.is_set())
+ self.assertEqual(proc.exitcode, 0)
+ finally:
+ setattr(sys, stream_name, old_stream)
+
+ def test_error_on_stdio_flush_2(self):
+ # Same as test_error_on_stdio_flush_1(), but standard streams are
+ # broken by the child process
+ for stream_name in ('stdout', 'stderr'):
+ for action in ('close', 'remove'):
+ old_stream = getattr(sys, stream_name)
+ try:
+ evt = self.Event()
+ proc = self.Process(target=self._test_error_on_stdio_flush,
+ args=(evt, {stream_name: action}))
+ proc.start()
+ proc.join()
+ self.assertTrue(evt.is_set())
+ self.assertEqual(proc.exitcode, 0)
finally:
setattr(sys, stream_name, old_stream)