Module: testing.decorators
5 Functions
- IPython.testing.decorators.skipif(skip_condition: bool, msg: str | None = None) MarkDecorator
Make function raise SkipTest exception if skip_condition is true
- Parameters:
skip_condition (bool or callable) – Flag to determine whether to skip test. If the condition is a callable, it is used at runtime to dynamically make the decision. This is useful for tests that may require costly imports, to delay the cost until the test suite is actually executed.
msg (string) – Message to give on raising a SkipTest exception.
- Returns:
decorator – Decorator, which, when applied to a function, causes SkipTest to be raised when the skip_condition was True, and the function to be called normally otherwise.
- Return type:
function
- IPython.testing.decorators.skip(msg: str | None = None) MarkDecorator
Decorator factory - mark a test function for skipping from test suite.
- Parameters:
msg (string) – Optional message to be added.
- Returns:
decorator – Decorator, which, when applied to a function, causes SkipTest to be raised, with the optional message added.
- Return type:
function
- IPython.testing.decorators.onlyif(condition: bool, msg: str) MarkDecorator
The reverse from skipif, see skipif for details.
- IPython.testing.decorators.module_not_available(module: str) bool
Can module be imported? Returns true if module does NOT import.
This is used to make a decorator to skip tests that require module to be available, but delay the ‘import numpy’ to test execution time.
- IPython.testing.decorators.onlyif_cmds_exist(*commands)
Decorator to skip test when at least one of
commandsis not found.