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

Function _mock_aware_unwrap

src/_pytest/doctest.py:476–491  ·  view source on GitHub ↗
(
        func: Callable[..., Any], *, stop: Callable[[Any], Any] | None = None
    )

Source from the content-addressed store, hash-verified

474 real_unwrap = inspect.unwrap
475
476 def _mock_aware_unwrap(
477 func: Callable[..., Any], *, stop: Callable[[Any], Any] | None = None
478 ) -> Any:
479 try:
480 if stop is None or stop is _is_mocked:
481 return real_unwrap(func, stop=_is_mocked)
482 _stop = stop
483 return real_unwrap(func, stop=lambda obj: _is_mocked(obj) or _stop(func))
484 except Exception as e:
485 warnings.warn(
486 f"Got {e!r} when unwrapping {func!r}. This is usually caused "
487 "by a violation of Python's object protocol; see e.g. "
488 "https://github.com/pytest-dev/pytest/issues/5080",
489 PytestWarning,
490 )
491 raise
492
493 inspect.unwrap = _mock_aware_unwrap
494 try:

Callers

nothing calls this directly

Calls 2

_is_mockedFunction · 0.85
warnMethod · 0.45

Tested by

no test coverage detected