MCPcopy Index your code
hub / github.com/ipython/ipython / skipif

Function skipif

IPython/testing/decorators.py:14–39  ·  view source on GitHub ↗

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

(skip_condition: bool, msg: Optional[str]=None)

Source from the content-addressed store, hash-verified

12from typing import Optional
13
14def skipif(skip_condition: bool, msg: Optional[str]=None) -> MarkDecorator:
15 """Make function raise SkipTest exception if skip_condition is true
16
17 Parameters
18 ----------
19
20 skip_condition : bool or callable
21 Flag to determine whether to skip test. If the condition is a
22 callable, it is used at runtime to dynamically make the decision. This
23 is useful for tests that may require costly imports, to delay the cost
24 until the test suite is actually executed.
25 msg : string
26 Message to give on raising a SkipTest exception.
27
28 Returns
29 -------
30 decorator : function
31 Decorator, which, when applied to a function, causes SkipTest
32 to be raised when the skip_condition was True, and the function
33 to be called normally otherwise.
34 """
35 if msg is None:
36 msg = "Test skipped due to test condition."
37
38 assert isinstance(skip_condition, bool)
39 return pytest.mark.skipif(skip_condition, reason=msg)
40
41
42# A version with the condition set to true, common case just to attach a message

Callers 3

skipFunction · 0.85
onlyifFunction · 0.85
decorators.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…