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@skipor@skip()) → test is unconditionally skippedTrue→ test is skippedFalse→ test runs normally (no-op)Callable→ invoke at test time; skip if it returnsTrue
Returns#
- T
The original target with
__punit_skip_conditionset.
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