Return if an object is possibly a mock object by checking the existence of a highly improbable attribute.
(obj: object)
| 459 | |
| 460 | |
| 461 | def _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 |
no test coverage detected