[Twisted-Python] How to find out if exceptions are being raised in your errBack?

Glyph Lefkowitz glyph at twistedmatrix.com
Wed Oct 14 08:45:28 EDT 2009

On Wed, Oct 14, 2009 at 4:43 AM, Steve Steiner (listsin) <
listsin at integrateddevcorp.com> wrote:

> On Oct 14, 2009, at 2:07 AM, Glyph Lefkowitz wrote:
> Yes, we're working on it but it's a large code base and we started with
> exactly zero tests.  While that leaves infinite room for improvement, it's a
> little overwhelming.  Oh well, at least we know where to concentrate first
> ;-0.

I realize it's a challenge, but, well, "Doctor, doctor, it hurts when I
don't do this!".  My immediate reaction is "go ahead and do it, then" :-).

> Trial will helpfully fail tests which cause exceptions to be logged, so you
> don't need to write any special extra test to make sure that nothing is
> blowing up; just test your error-handling case, and if it blows up you will
> see it.
> We've just been using nose; is that something Trial handles specially for
> Twisted?


> If you want to handle logged exceptions specially, for example to put them
> in a separate file, or to e-mail them to somebody, consider writing a log
> observer that checks for the isError key and does something special there.
> You can find out more about writing log observers here: <
> http://twistedmatrix.com/projects/core/documentation/howto/logging.html>.
> This is an area of Twisted I haven't explored at all since the code's all
> using the standard Python logging.
> That's the thing about Twisted; sometimes it's hard to know whether the
> stuff that has been built into standard Python since Twisted 'rolled their
> own' is a superset, a subset, or a completely different beast.  Logging is a
> good case in point.  Since we're using Python's logging everywhere, I wasn't
> even sure whether there would be an advantage to learning Twisted's similar
> system.  Twisted's trial is another example; we've just been using nose.
>  Seems like there's always some little extra that makes the Twisted stuff
> worth knowing.

Another option here would be to set up a PythonLoggingObserver that relay's
Twisted's log messages to Python standard logging, then setup a standard log
handler (another poster suggests nose already does this) to fail the test
when appropriate.  I'm fairly sure that the information you need is being
properly relayed to the relevant parties, but if I'm wrong, it's a bug and
probably a pretty easy one to fix :).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://twistedmatrix.com/pipermail/twisted-python/attachments/20091014/4828fde8/attachment-0001.htm 

More information about the Twisted-Python mailing list