Issue 1955: fix using unittest as a superclass
Issue1955
Created on 2008-01-28 14:39 by agoucher, last changed 2022-04-11 14:56 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| cpython-unittest-subclass.diff | agoucher, 2008-01-28 14:39 | cpython-unittest-subclass.diff | ||
| Messages (3) | |||
|---|---|---|---|
| msg61776 - (view) | Author: Adam Goucher (agoucher) | Date: 2008-01-28 14:39 | |
There are a couple places in unittest where 'issubclass(something,
TestCase)' is used. This prevents you from organizing your test code via
class hierarchies. To solve this problem, issubclass should be looking
whether the object is a subclass of unittest.TestCase to walk the
inheritance tree all the way up and not just a single level.
Currently, this will not 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 a patch which will address all locations where this
could happen.
|
|||
| msg61780 - (view) | Author: Antoine Pitrou (pitrou) * ![]() |
Date: 2008-01-28 15:09 | |
I don't really understand what problem you are trying to solve. Can you attach a sample script to show it more clearly? Also, the only thing your patch does is rename Test(Case|Suite) references to unittest.Test(Case|Suite)... I doubt it would have any effect unless you were monkeypatching the unittest module to replace those classes with other ones (which should certainly be considered very dirty ;-)). |
|||
| msg61782 - (view) | Author: Guido van Rossum (gvanrossum) * ![]() |
Date: 2008-01-28 15:57 | |
This patch seems to be based upon a misunderstanding of how Python namespaces work. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022-04-11 14:56:30 | admin | set | github: 46247 |
| 2008-01-28 15:57:32 | gvanrossum | set | status: open -> closed keywords: + patch resolution: rejected messages: + msg61782 nosy: + gvanrossum |
| 2008-01-28 15:10:00 | pitrou | set | nosy:
+ pitrou messages: + msg61780 |
| 2008-01-28 14:39:33 | agoucher | create | |
