MCPcopy
hub / github.com/pytest-dev/pytest / ishidden

Method ishidden

src/_pytest/_code/code.py:314–337  ·  view source on GitHub ↗

Return True if the current frame has a var __tracebackhide__ resolving to True. If __tracebackhide__ is a callable, it gets called with the ExceptionInfo instance and can decide whether to hide the traceback. Mostly for internal use.

(self, excinfo: ExceptionInfo[BaseException] | None)

Source from the content-addressed store, hash-verified

312 source = property(getsource)
313
314 def ishidden(self, excinfo: ExceptionInfo[BaseException] | None) -> bool:
315 """Return True if the current frame has a var __tracebackhide__
316 resolving to True.
317
318 If __tracebackhide__ is a callable, it gets called with the
319 ExceptionInfo instance and can decide whether to hide the traceback.
320
321 Mostly for internal use.
322 """
323 tbh: bool | Callable[[ExceptionInfo[BaseException] | None], bool] = False
324 for maybe_ns_dct in (self.frame.f_locals, self.frame.f_globals):
325 # in normal cases, f_locals and f_globals are dictionaries
326 # however via `exec(...)` / `eval(...)` they can be other types
327 # (even incorrect types!).
328 # as such, we suppress all exceptions while accessing __tracebackhide__
329 try:
330 tbh = maybe_ns_dct["__tracebackhide__"]
331 except Exception:
332 pass
333 else:
334 break
335 if tbh and callable(tbh):
336 return tbh(excinfo)
337 return tbh
338
339 def __str__(self) -> str:
340 name = self.frame.code.name

Callers 3

filterMethod · 0.80
_getreprcrashMethod · 0.80
test_skip_simpleMethod · 0.80

Calls

no outgoing calls

Tested by 1

test_skip_simpleMethod · 0.64