HomePhabricator

Use freezegun module for time-sensitive tests
fc3f94e1ded6Unpublished

Tags
None
Referenced Files
None
Subscribers
None

Unpublished Commit · Learn More

Publishing Disabled: All publishing is disabled for this repository.

Description

Use freezegun module for time-sensitive tests

Since we only use second-resolution timestamps (since commit 8ad626f1c9
and 07d8c6c83b), if we want to ensure an ordering between timestamps we
need to ensure that the store sees at least one second elapse between
them. Previously, we did this by actually sleeping for one second each
time, but this has the obvious disadvantage of significantly slowing
down the tests because they have to sleep all the time. Instead, we can
use the freezegun module, which mocks the datetime module, allowing us
to freeze time at arbitrary points, and also gives us a nicely
convenient tick() method to advance the frozen time by one second.

This cuts the time to run the non-database tests from over eight seconds
to around one second.

Details

Provenance
LucasWerkmeisterAuthored on Apr 28 2019, 5:03 PM
Parents
R2494:9d3c6e3dc301: Suspend background runs on some errors
Branches
Unknown
Tags
Unknown
ChangeId
None