New submission from R. David Murray: I have a situation where it would be really helpful to know in my cleanup routine whether or not the test failed. The situation is this: I'm running a command in a subprocess, and sometimes it writes output to stderr that I normally want to ignore. But if the test fails, I'd like my cleanup routine (that shuts down the test subprocess) to print out the stderr, because usually the information as to what went wrong is in stderr.
I figure out this hack (for python3.4): for what, result in self._outcome.errors: if what._testMethodName == self._testMethodName and result: print(self.p.stderr.read().decode()) but obviously that uses non-public APIs. ---------- keywords: easy messages: 243694 nosy: ezio.melotti, michael.foord, r.david.murray, rbcollins priority: normal severity: normal stage: needs patch status: open title: unittest API for detecting test failure in cleanup/teardown type: enhancement versions: Python 3.6 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue24249> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com