[Zope3-dev] Patching zope.testing
Hello folks, I'd change slightly the output format of the log handler in zope.testing.loggingsupport so that one is able to see *what* went wrong when an exception is logged. For instance, rather than getting just: zope.app.generations ERROR Failed to evolve database to generation 4 for app1 One would get: zope.app.generations ERROR Failed to evolve database to generation 4 for app1 Traceback (most recent call last): ... ValueError: 4 Even though this is a simple change, it'll break a few tests in the Zope 3 tree, and perhaps other projects using the same test runner (is anyone else using it?). With this in mind, and considering that I haven't been following the development as closely as I should, I'd like to check with you if it's ok to apply the change at this point to the trunk of zope.testing and update the svn:external link of Zope3 trunk while fixing the broken tests, or if there's another less disruptive way of doing it. The patch is the following one. Notice that in addition to introduce backtraces, it'll also indent all lines to 2 spaces, rather than just the first one (so that all of them are identified as pertaining to the given log message). Index: loggingsupport.py === --- loggingsupport.py (revision 69092) +++ loggingsupport.py (working copy) @@ -105,16 +105,16 @@ logger.removeHandler(self) def __str__(self): -return '\n'.join( -[(%s %s\n %s % - (record.name, record.levelname, - '\n'.join([line - for line in record.getMessage().split('\n') - if line.strip()]) - ) - ) - for record in self.records] - ) +lines = [] +for record in self.records: +lines.append(%s %s % (record.name, record.levelname)) +for line in record.getMessage().split(\n): +if line.strip(): +lines.append( +line) +if record.exc_info and record.exc_info[0] and record.exc_text: +for line in record.exc_text.split(\n): +lines.append( +line) +return '\n'.join(lines) class InstalledHandler(Handler): -- Gustavo Niemeyer http://niemeyer.net ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] Patching zope.testing
On 9/5/06, Gustavo Niemeyer [EMAIL PROTECTED] wrote: runner (is anyone else using it?). We're certainly using the zope.testing framework for internal projects; I expect a number of projects would be affected. In thinking about this, it's not at all clear to me that this is the right thing to do. When checking logging output, what's really being checked is that a usable log entry is being made at the right level. If what you want is to test an exception, that seems to be a distinct test (IMO, of course). -Fred -- Fred L. Drake, Jr.fdrake at gmail.com Every sin is the result of a collaboration. --Lucius Annaeus Seneca ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] Patching zope.testing
On Sep 5, 2006, at 1:10 PM, Fred Drake wrote: On 9/5/06, Gustavo Niemeyer [EMAIL PROTECTED] wrote: runner (is anyone else using it?). We're certainly using the zope.testing framework for internal projects; I expect a number of projects would be affected. In thinking about this, it's not at all clear to me that this is the right thing to do. When checking logging output, what's really being checked is that a usable log entry is being made at the right level. If what you want is to test an exception, that seems to be a distinct test (IMO, of course). I agree. zope.testing.loggingsupport is for testing logging, not for logging while testing. :) Jim -- Jim Fulton mailto:[EMAIL PROTECTED]Python Powered! CTO (540) 361-1714 http://www.python.org Zope Corporationhttp://www.zope.com http://www.zope.org ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] Patching zope.testing
I agree. zope.testing.loggingsupport is for testing logging, not for logging while testing. :) Can you do one without the other? :-) Please check my answer to Fred. -- Gustavo Niemeyer http://niemeyer.net ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com
Re: [Zope3-dev] Patching zope.testing
I agree. zope.testing.loggingsupport is for testing logging, not for logging while testing. :) Can you do one without the other? :-) Please check my answer to Fred. -- Gustavo Niemeyer http://niemeyer.net ___ Zope3-dev mailing list Zope3-dev@zope.org Unsub: http://mail.zope.org/mailman/options/zope3-dev/archive%40mail-archive.com