nose-devs/nose — Issue #443: logcapture doesn't nicely handle log format exceptions
Author: jpellerin
Created: 2011-12-14 16:11:44+00:00
State: open

What steps will reproduce the problem?
1. Have a log handler that throws an exception on formatting the log

What is the expected output? What do you see instead?

See the test output skip the "ok" or "FAIL" etc for that test and skip right to the next test, counting that test as skipped

What version of the product are you using? On what operating system?
nosetests version 1.1.2 on ubuntu 10.4

Please provide any additional information below.
Here is what fixes it for me, or at least lets the test actually fail:

diff -r 43d9088a4553 nose/plugins/logcapture.py
--- a/nose/plugins/logcapture.py	Fri Aug 05 10:26:21 2011 -0500
+++ b/nose/plugins/logcapture.py	Wed Aug 24 15:32:49 2011 -0400
@@ -228,7 +228,10 @@

def formatLogRecords(self):
format = self.handler.format
- return [safe_str(format(r)) for r in self.handler.buffer]
+ try:
+ return [safe_str(format(r)) for r in self.handler.buffer]
+ except TypeError:
+ return [safe_str(r) for r in self.handler.buffer]

def addCaptureToErr(self, ev, records):
return '\n'.join([safe_str(ev), ln('>> begin captured logging <<')] + \

This will have the log message be unproperly formatted, but it's better than the entire test being swallowed completely.

Google Code Info:
Issue #: 449
Author: s...@lot18.com
Created On: 2011-08-24T19:33:30.000Z
Closed On: