(
func: Callable[..., Any], *, stop: Callable[[Any], Any] | None = None
)
| 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: |
nothing calls this directly
no test coverage detected