Python Unittest2 - avoid including TestCase in open ()

I use unittest2in Python2.5to detect tests using unittest.TestLoader.discover, for example:

suite = unittest2.loader.TestLoader().discover(test_path)
unittest2.TextTestRunner(verbosity=2,
        resultclass=ColorTestResult).run(suite)

for some test_pathin the base of my project.

I have a base class that is extended and overloaded by many others, but I would like to check that these derivatives do not have regressions. Let me call this base class Aand its derivatives A1, A2etc.

I would like to create a base class unittest2.TestCasethat can be overloaded for each of the derivatives of A. In other words, I would like to have a hierarchy something like this:

class A:
    pass

class A1(A):
    pass

class UT(unittest2.TestCase):
    target = A

class UT2(UT):
    target = A1

, A , UT , UT2 ..

, , unittest2 discover - "" UT. , , , "test *.py", , , .

- , ?

.

+3
1

, , UT2 UT, , UT2 , UT - , , . , , UT, TestCase UT2.

TestCases, .

. UT , , UT2, UT :

class UT2(get_base_class()):
    target = A1

UT super().

, , UT . UT ( , ?) setUp skipTest, ( A).

, UT TestCase, mixin:

class UT2(TestCase, UT):
     target = A1
+2

All Articles