diff --git a/IPython/utils/tests/test_process.py b/IPython/utils/tests/test_process.py index dc12a7c..a4369e3 100644 --- a/IPython/utils/tests/test_process.py +++ b/IPython/utils/tests/test_process.py @@ -26,6 +26,7 @@ import nose.tools as nt from IPython.utils.process import (find_cmd, FindCmdError, arg_split, system, getoutput, getoutputerror, get_output_error_code) +from IPython.utils.capture import capture_output from IPython.testing import decorators as dec from IPython.testing import tools as tt @@ -149,6 +150,16 @@ class SubProcessTestCase(tt.TempFileMixin): status, 0, "The process wasn't interrupted. Status: %s" % (status,) ) + def test_stderr_while_stdout_open(self): + """ + If lots of data is written to stderr while stdout is still open, enough + data to fill the pipe buffer in fact, the process still exits (i.e. + there is no deadlock). + """ + with capture_output(display=False): + system(("%s -c 'import sys\nfor i in range(2000): " + + "sys.stderr.write(\" \" * 100 + \"\\n\")'") % (python,)) + def test_getoutput(self): out = getoutput('%s "%s"' % (python, self.fname)) # we can't rely on the order the line buffered streams are flushed