jeudi 26 mai 2016

Pytest Ignore Parent Tests

I am writing some tests against a series of objects that all part of a large inheritance tree.

class A(object):
    # stuff

class B(A):
    # more stuff

class C(B):
    # even more stuff

I am writing tests in pytest, and it makes sense to copy the same tree within my test classes. To continue with the example.

class TestA(unittest.TestCase):
    setUp(self):
        # some prep

    def test_a(self):
        # a test for A

class TestB(TestA):
    setUp(self):
        super(TestB, self).setUp()

    def test_b(self):
        # a test for B

class TestC(TestB):
    setUp(self):
        super(TestC, self).setUp()

    def test_c(self):
        # a test for C

Everything is running great, except I am wondering if it is possible to have pytest ignore running tests that are inherited from parent classes. For example, when TestC is run, it runs test_a, test_b, and test_c. test_a, and test_b are already being discovered and tested for the class TestB and TestA, so I'd like to remove some unnecessary testing time.

Aucun commentaire:

Enregistrer un commentaire