punit.conditions#

skip(when=None)#

Decorator that marks a test for conditional or unconditional skip.

Return type:

Callable[[TypeVar(T, bound= Callable[..., object])], TypeVar(T, bound= Callable[..., object])]

Parameters#

whenbool | Callable[…, bool] | None

Controls skip behavior:

  • None (bare @skip or @skip()) → test is unconditionally skipped

  • True → test is skipped

  • False → test runs normally (no-op)

  • Callable → invoke at test time; skip if it returns True

Returns#

T

The original target with __punit_skip_condition set.

Example#

from punit import skip

@skip()
def test_always_skipped():
    pass

@skip(True)
def test_skipped():
    pass

@skip(False)
def test_runs():
    pass

@skip(lambda: os.name == 'posix')
def test_conditional():
    pass