SagyDrucker
SagyDrucker

Reputation: 21

python unittest skip test without super

I have tried various things like raising Skip() but nothing works, everything simply fails my entire tests.

I have code similar to:

class ConfigPageTest(BaseTestClass):

@unittest.skipIf(isWindows, 'msg')
def test_three(self):
    pass

the problem is, when i want to skip a test, i do NOT want to run it's base class's super(). i.e. my program fails because although i am skipping the test, i am still running the "BaseTestClass" constructor. which fails sue to the isWindows. How can I skip the test without running the constructor?

Upvotes: 1

Views: 181

Answers (1)

Oleksiy
Oleksiy

Reputation: 6567

Sounds like you may want to raise SkipTest exception in your BaseTestClass constructor, or right before your failing code, something like this:

from unittest.case import SkipTest

# before your current failing platform specific code
if isWindows():
    raise SkipTest("skipping this test on Windows")

Upvotes: 1

Related Questions