Mocks _pytest.timing with a known object that can be used to control timing in tests deterministically. pytest itself should always use functions from `_pytest.timing` instead of `time` directly. This then allows us more control over time during testing, if testing code also uses `
(monkeypatch: MonkeyPatch)
| 221 | |
| 222 | @pytest.fixture |
| 223 | def mock_timing(monkeypatch: MonkeyPatch): |
| 224 | """Mocks _pytest.timing with a known object that can be used to control timing in tests |
| 225 | deterministically. |
| 226 | |
| 227 | pytest itself should always use functions from `_pytest.timing` instead of `time` directly. |
| 228 | |
| 229 | This then allows us more control over time during testing, if testing code also |
| 230 | uses `_pytest.timing` functions. |
| 231 | |
| 232 | Time is static, and only advances through `sleep` calls, thus tests might sleep over large |
| 233 | numbers and obtain accurate time() calls at the end, making tests reliable and instant. |
| 234 | """ |
| 235 | from _pytest.timing import MockTiming |
| 236 | |
| 237 | result = MockTiming() |
| 238 | result.patch(monkeypatch) |
| 239 | return result |
| 240 | |
| 241 | |
| 242 | @pytest.fixture(autouse=True) |
nothing calls this directly
no test coverage detected
searching dependent graphs…