| 195 | |
| 196 | @attr.s |
| 197 | class MockTiming: |
| 198 | |
| 199 | _current_time = attr.ib(default=1590150050.0) |
| 200 | |
| 201 | def sleep(self, seconds): |
| 202 | self._current_time += seconds |
| 203 | |
| 204 | def time(self): |
| 205 | return self._current_time |
| 206 | |
| 207 | def patch(self): |
| 208 | from _pytest import timing |
| 209 | |
| 210 | monkeypatch.setattr(timing, "sleep", self.sleep) |
| 211 | monkeypatch.setattr(timing, "time", self.time) |
| 212 | monkeypatch.setattr(timing, "perf_counter", self.time) |
| 213 | |
| 214 | result = MockTiming() |
| 215 | result.patch() |