Issue 36647: TextTestRunner doesn't honour "buffer" argument (original) (raw)
When using "buffer = True" in a TextTestRunner, the test result behaviour doesn't change at all.
This is because TextTestRunner.stream is initialised using a decorator (_WritelnDecorator). When "buffer" is passed, the TestResult base class will try to redirect the stdout and stderr to 2 different io.StringIO objects. As the TextTestRunner.stream is initialised before that "redirection", all the "self.stream.write" calls will end using the original stream (stderr by default), and resulting in not buffering at all.