How can I hide my stack frames in a TestCase subclass?

Manuel Pégourié-Gonnard mpg at elzevir.fr
Fri Oct 5 02:28:22 EDT 2012


Peter Otten scripsit :

> David Banks wrote:
>
>> Note that the custom assert method causes a stack trace with two frames,
>> one inside the method itself, whereas the stock unittest method only has
>> one frame, the relevant line in the user's code.  How can I apply this
>> frame-hiding behaviour to my own method?
>
> Move MyTestCase in a separate module and define a global variable 
>
> __unittest = True
>
Hum, is it documented somewhere? I can't find it in the doc. Also, I'm
curious to know what kind of magic it's using.

-- 
Manuel Pégourié-Gonnard - http://people.math.jussieu.fr/~mpg/





More information about the Python-list mailing list