Grandchildren of TestCase don't work
Gabriel Genellina
gagsl-py2 at yahoo.com.ar
Wed Aug 20 03:32:06 EDT 2008
En Tue, 19 Aug 2008 18:35:57 -0300, Gustavo Narea <me at gustavonarea.net>
escribi�:
> Hello, everyone.
>
> Why do unitest.TestCase grand-grandchildren not work?
>
> I've created a unittest.TestCase descendant, which contains the setUp()
> and
> tearDown() for testing some components of a web framework. Every
> application based on this framework should subclass this base class once,
> and the rest of the test cases must also subclass the base TestCase of
> the
> application (which is a direct descendant of my descendant of TestCase).
Do you have any reason for such meta-testing?
If you want to ensure that all derived Test classes correctly set the
database and model attributes, just check that condition in another test
method on your base class (DBTest).
Currently you are trying to check whether the code is actually checking
the condition... I'm not sure of the usefulness of such meta-testing, even
if it worked.
> But grandchildren of my TestCase don't work, and I get this weird error:
>> File "/usr/lib/python2.5/unittest.py", line 248, in run
>> testMethod = getattr(self, self._testMethodName)
>> AttributeError: 'TestDatabaseGrandChildTesting' object has no
>> attribute '_testMethodName'
I get a different exception: ValueError: no such test method in <class
'__main__.EmptyTestCase'>: runTest, which is perfectly reasonable given
that you're constructing TestCase instances by hand, with no arguments -
so the default test method "runTest" is used, and you haven't provided
such method.
--
Gabriel Genellina
More information about the Python-list
mailing list