subclassing from unittest
Roy Smith
roy at panix.com
Thu May 23 08:43:59 EDT 2013
In article <bar07a-pca.ln1 at satorlaser.homedns.org>,
Ulrich Eckhardt <ulrich.eckhardt at dominolaser.com> wrote:
> if you have an intermediate class derived
> from unittest.TestCase, that class on its own will be considered as test
> case! If this is not what you want but you still want common
> functionality in a baseclass, create a mixin and then derive from both
> the mixin and unittest.TestCase for the actual test cases.
Or, try another trick I picked up somewhere. When you're done defining
your test classes, delete the intermediate base class, so it won't be
autodiscovered!
class MyBaseTestClass(unittest.TestCase):
pass
class MyRealTest1(MyBaseTestClass):
pass
class MyRealTest2(MyBaseTestCalss):
pass
del MyBaseTestClass
More information about the Python-list
mailing list