bobber6467 / python-nose

Automatically exported from code.google.com/p/python-nose
0 stars 0 forks source link

logcapture doesn't nicely handle log format exceptions #449

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
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.

Original issue reported on code.google.com by s...@lot18.com on 24 Aug 2011 at 7:33