Return if an object is possibly a mock object by checking the existence of a highly improbable attribute.
(obj: object)
| 558 | |
| 559 | |
| 560 | def _is_mocked(obj: object) -> bool: |
| 561 | """Return if an object is possibly a mock object by checking the |
| 562 | existence of a highly improbable attribute.""" |
| 563 | return ( |
| 564 | safe_getattr(obj, "pytest_mock_example_attribute_that_shouldnt_exist", None) |
| 565 | is not None |
| 566 | ) |
| 567 | |
| 568 | |
| 569 | @contextmanager |
no outgoing calls
no test coverage detected
searching dependent graphs…