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

Function _is_mocked

src/_pytest/doctest.py:461–467  ·  view source on GitHub ↗

Return if an object is possibly a mock object by checking the existence of a highly improbable attribute.

(obj: object)

Source from the content-addressed store, hash-verified

459
460
461def _is_mocked(obj: object) -> bool:
462 """Return if an object is possibly a mock object by checking the
463 existence of a highly improbable attribute."""
464 return (
465 safe_getattr(obj, "pytest_mock_example_attribute_that_shouldnt_exist", None)
466 is not None
467 )
468
469
470@contextmanager

Callers 1

_mock_aware_unwrapFunction · 0.85

Calls 1

safe_getattrFunction · 0.90

Tested by

no test coverage detected