Python unittest, skip tests when using a base-test-class

Viewed 3367

Whilst testing one of our web-apps for clarity I have created a BaseTestClass which inherits unittest.TestCase. The BaseTestClass includes my setUp() and tearDown() methods, which each of my <Page>Test classes then inherit from.

Due to different devices under test having similar pages with some differences I wanted to use the @unittest.skipIf() decorator but its proving difficult. Instead of 'inheriting' the decorator from BaseTestClass, if I try to use that decorator Eclipse tries to auto-import unittest.TestCase into <Page>Test, which doesn't seem right to me.

Is there a way to use the skip decorators when using a Base?

class BaseTestClass(unittest.TestCase):

    def setUp():
        #do setup stuff
        device = "Type that blocks"

    def tearDown():
        #clean up

One of the test classes in a separate module:

class ConfigPageTest(BaseTestClass):

    def test_one(self):
        #do test

    def test_two(self):
        #do test

    @unittest.skipIf(condition, reason) <<<What I want to include
    def test_three(self):
        #do test IF not of the device type that blocks
1 Answers
Related