[New-bugs-announce] [issue13236] unittest needs more flush calls
Peter Eisentraut
report at bugs.python.org
Thu Oct 20 21:02:04 CEST 2011
New submission from Peter Eisentraut <peter_e at gmx.net>:
I'm using the TextTestRunner class in unittest/runner.py with a special file-like object passed in as stream. Doing this loses some output, because the run() method (and some lower-level methods) don't always call flush() on the stream. There is also no obvious cleanup method in the runner class that might do this, so I assume run() should do that itself.
Right now, it looks like it assumes that either the stream is effectively unbuffered, like stderr, or that the end of the program might flush things, but that doesn't always apply.
It looks like the best fix would be a self.stream.flush() call at the end of run(). Another flush() call at the end of printErrorList() would also help.
(In the meantime, I have fixed up my special file-like class to flush its internal buffers when a newline is seen, which kind of works, but a proper cleanup of this matter would still be nice.)
----------
components: Library (Lib)
messages: 146043
nosy: petere
priority: normal
severity: normal
status: open
title: unittest needs more flush calls
type: behavior
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue13236>
_______________________________________
More information about the New-bugs-announce
mailing list