Issue1878473

classification
Title: fixing inheritance in unittest.py
Type: Severity: normal
Components: Library Versions:
Milestone:
process
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: agoucher, zyasoft
Priority: normal Keywords:

Created on 2008-01-23.20:28:30 by agoucher, last changed 2009-03-08.06:39:13 by zyasoft.

Files
File name Uploaded Description Edit Remove
unittest-subclass.patch agoucher, 2008-01-23.20:28:30 patch
Messages
msg2062 (view) Author: Adam Goucher (agoucher) Date: 2008-01-23.20:28:30
I tripped over a partially fixed problem in unittest.py today.

loadTestsFromName has been changed already to look whether the class it is looking in for tests is subclassed from unittest.TestCase. loadTestsFromModule however still just looks for TestCase. This results in not being able to find tests in a class that is not a direct subclass of TestCase.

The following structure currently won't work:
module A..
class A(unittest.TestCase):
    pass

module B...
import A

class B(A.A)
    def testFoo(self):
        print "blah blah blah"

I have attached the patch to fix this.
msg4192 (view) Author: Jim Baker (zyasoft) Date: 2009-03-08.06:39:09
We use the same unittest as CPython 2.5, and the example mentioned works
the same in both, as would be expected.
History
Date User Action Args
2009-03-08 06:39:13zyasoftsetstatus: open -> closed
resolution: works for me
messages: + msg4192
nosy: + zyasoft
2008-01-23 20:28:30agouchercreate