[TIP] Grand children of TestCase don't work
Jean-Paul Calderone
exarkun at divmod.com
Wed Aug 20 06:38:57 PDT 2008
On Wed, 20 Aug 2008 13:07:06 +0200, Gustavo Narea <me at gustavonarea.net> wrote:
>Hello, Jonathan.
>
>It fails even without call_dad: http://paste.turbogears.org/paste/4721
>
>I think the real problem is that it's impossible to test TestCase objects:
>> >>> import unittest
>> >>> class algo(unittest.TestCase):
>> ... i_am_a_variable = True
>> ...
>> >>> my_var = algo()
>> Traceback (most recent call last):
>> File "<stdin>", line 1, in <module>
>> File "/usr/lib/python2.5/unittest.py", line 209, in __init__
>> (self.__class__, methodName)
>> ValueError: no such test method in <class '__main__.algo'>: runTest
>
>Am I right?
You're missing the fact that TestCase takes an argument to __init__, the
name of the method which will run a test. The default is "runTest",
which is not defined on your "algo" subclass. You need to define that
method, or some other method and pass its name to the initializer.
Jean-Paul
More information about the testing-in-python
mailing list