[Twisted-Python] Naming test methods constructed with deferredGenerator - is it possible?

Jean-Paul Calderone exarkun at divmod.com
Fri Apr 28 07:57:48 MDT 2006


On Fri, 28 Apr 2006 15:36:32 +0200, Marcin Kasperski <marcin.kasperski at softax.com.pl> wrote:
>> I think this may be fixed in twisted 2.2.
>
>My Debian claims that I am using 2.2.0, so maybe it was patched
>later.
>
>I guess that the fix would be adding within deferredGenerator
>construct like the one suggested by Mike (setting __doc__ of
>returned lambda function to __name__ of wrapped function)

This isn't correct, of course.  It just happens to do something kind of useful when the deferred generator is a trial test method.  In other cases, it would be weird to find the __doc__ of the returned object to be the __name__ of the wrapped function.

In Python 2.4, setting __name__ works, and deferredGenerator tries to do that, so trial will only have this problem with Python 2.3.  You could define a helper function for your tests which calls deferredGenerator and sets __doc__ appropriately, if switching to Python 2.4 isn't an option.

Jean-Paul




More information about the Twisted-Python mailing list