MCPcopy Create free account
hub / github.com/ipython/ipython / knownfailureif

Function knownfailureif

IPython/external/decorators/_decorators.py:103–143  ·  view source on GitHub ↗

Make function raise KnownFailureTest exception if given condition is true. Parameters ---------- fail_condition : bool Flag to determine whether to mark the decorated test as a known failure (if True) or not (if False). msg : str, optional Message to giv

(fail_condition, msg=None)

Source from the content-addressed store, hash-verified

101 return skip_decorator
102
103def knownfailureif(fail_condition, msg=None):
104 """
105 Make function raise KnownFailureTest exception if given condition is true.
106
107 Parameters
108 ----------
109 fail_condition : bool
110 Flag to determine whether to mark the decorated test as a known
111 failure (if True) or not (if False).
112 msg : str, optional
113 Message to give on raising a KnownFailureTest exception.
114 Default is None.
115
116 Returns
117 -------
118 decorator : function
119 Decorator, which, when applied to a function, causes KnownFailureTest to
120 be raised when `fail_condition` is True and the test fails.
121
122 Notes
123 -----
124 The decorator itself is decorated with the ``nose.tools.make_decorator``
125 function in order to transmit function name, and various other metadata.
126
127 """
128 if msg is None:
129 msg = 'Test skipped due to known failure'
130
131 def knownfail_decorator(f):
132 # Local import to avoid a hard nose dependency and only incur the
133 # import time overhead at actual test-time.
134 import nose
135
136 def knownfailer(*args, **kwargs):
137 if fail_condition:
138 raise KnownFailureTest(msg)
139 else:
140 return f(*args, **kwargs)
141 return nose.tools.make_decorator(f)(knownfailer)
142
143 return knownfail_decorator

Callers 1

decorators.pyFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected