0

Is there a way to skip unit tests depending on the platform? I have linux specific nosetests that use linux only libraries, that I would like to skip on our mac build.

Community
  • 1
  • 1
vidstige
  • 12,492
  • 9
  • 66
  • 110

1 Answers1

1

Apparently, you do it like so

Step one, create a decorator

def skip_if(condition):
    """Conditionally skips a test"""
    def wrapper(f):
        f.__test__ = not condition
        return f

    return wrapper

Step two, use sys.platform in your condition

import sys
@skip_if(sys.platform == "linux")
def test_linux_only()
    linus_torvalds()
vidstige
  • 12,492
  • 9
  • 66
  • 110