[TIP] Grand children of TestCase don't work

Gustavo Narea me at gustavonarea.net
Tue Aug 19 13:58:24 PDT 2008


Hello, everyone.

I've created a unittest.TestCase descendant, which contains some utilities
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).

But grandchildren of my TestCase don't work, and I get this weird error:
> .....Traceback (most recent call last):
>   File "pruebas.py", line 109, in <module>
>     unittest.main(defaultTest='suite')
>   File "/usr/lib/python2.5/unittest.py", line 768, in __init__
>     self.runTests()
>   File "/usr/lib/python2.5/unittest.py", line 805, in runTests
>     result = self.testRunner.run(self.test)
>   File "/usr/lib/python2.5/unittest.py", line 705, in run
>     test(result)
>   File "/usr/lib/python2.5/unittest.py", line 437, in __call__
>     return self.run(*args, **kwds)
>   File "/usr/lib/python2.5/unittest.py", line 433, in run
>     test(result)
>   File "/usr/lib/python2.5/unittest.py", line 437, in __call__
>     return self.run(*args, **kwds)
>   File "/usr/lib/python2.5/unittest.py", line 433, in run
>     test(result)
>   File "/usr/lib/python2.5/unittest.py", line 437, in __call__
>     return self.run(*args, **kwds)
>   File "/usr/lib/python2.5/unittest.py", line 433, in run
>     test(result)
>   File "/usr/lib/python2.5/unittest.py", line 281, in __call__
>     return self.run(*args, **kwds)
>   File "/usr/lib/python2.5/unittest.py", line 248, in run
>     testMethod = getattr(self, self._testMethodName)
> AttributeError: 'TestDatabaseGrandChildTesting' object has no
attribute '_testMethodName'

Isn't it possible to use grand-grandchildren of unittest.TestCase?

There's a file attached to reproduce this.

Cheers.
-- 
Gustavo Narea.
http://gustavonarea.net/

Get GNU/Linux! http://www.getgnulinux.org/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pruebas.py
Type: text/x-java
Size: 3158 bytes
Desc: not available
Url : http://lists.idyll.org/pipermail/testing-in-python/attachments/20080819/d8c77fe7/attachment.java 


More information about the testing-in-python mailing list