Lennart Regebro wrote:
This bugged me, so I had a dig, and just discovered this cool monkey
patch, to be inserted in any module that gets imported before an
exception is raised:

So, could this be in the unit test module itself, for example?

Well, like I said, I'm gonna roll up a load of these type patches into a little product and release it :-) (the benefits of this product would only be missed if an error occurred before it was imported, and the benefits aren't likely to be very beneficial at that stage ;-)

Ever noticed how it's near impossible to figure out what actually
causes an error when you run functional tests? Can you fix that too?

Depends what you mean by "functional tests"!

I used to do this in all my functional test cases:

    def getTraceback(self, response):
        return getattr(response._response, '_text_traceback', None)

    def assertResponse(self, response, status, message=''):
        if not response.getStatus() == status:
            tb = self.getTraceback(response)
            if tb is not None:
                raise self.failureException, tb
                raise ValueError, "Response had status %s, expected %s. %s" % (
                    response.getStatus(), status, message)

Hmm, if something failed, I'd just consult the event log, which I always copy all errors to.

And then end all my tests with:
        self.assertResponse(response, 200)

Sounds good, but we use Zelenium ;-)

And that _used_ to print out any exception that had occurred, but in
newer version of Zope this never happens. There sinmply never is and
_text_exception on the response anymore. Any ideas on how to get a
useable exception report on unit tests?

Ugh? on unit tests? my patch works exactly as I want on unit tests. What, specifically, are you referring to?



Simplistix - Content Management, Zope & Python Consulting
           - http://www.simplistix.co.uk

Zope maillist  -  Zope@zope.org
**   No cross posts or HTML encoding!  **
(Related lists - http://mail.zope.org/mailman/listinfo/zope-announce
http://mail.zope.org/mailman/listinfo/zope-dev )

Reply via email to