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

Function _mock_aware_unwrap

IPython/testing/plugin/pytest_ipdoctest.py:575–590  ·  view source on GitHub ↗
(
        func: Callable[..., Any], *, stop: Optional[Callable[[Any], Any]] = None
    )

Source from the content-addressed store, hash-verified

573 real_unwrap = inspect.unwrap
574
575 def _mock_aware_unwrap(
576 func: Callable[..., Any], *, stop: Optional[Callable[[Any], Any]] = None
577 ) -> Any:
578 try:
579 if stop is None or stop is _is_mocked:
580 return real_unwrap(func, stop=_is_mocked)
581 _stop = stop
582 return real_unwrap(func, stop=lambda obj: _is_mocked(obj) or _stop(func))
583 except Exception as e:
584 warnings.warn(
585 "Got %r when unwrapping %r. This is usually caused "
586 "by a violation of Python's object protocol; see e.g. "
587 "https://github.com/pytest-dev/pytest/issues/5080" % (e, func),
588 PytestWarning,
589 )
590 raise
591
592 inspect.unwrap = _mock_aware_unwrap
593 try:

Callers

nothing calls this directly

Calls 2

_is_mockedFunction · 0.85
warnMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…