pytest test passes alone but fails in the full suite, time-related
pytest 8.1, Python 3.11. I have a test asserting a timestamp is 'close to now' with abs(ts - time.time()) < 1. Passes when I run the file alone. In the full suite — about 400 tests, 90 seconds — it fails intermittently with a delta of 1.3s or so. Is there a plugin or pattern for freezing time reliably? I'd rather not change production code just to make a flaky assertion behave.
4 replies