-
-
Notifications
You must be signed in to change notification settings - Fork 1
Description
Currently, start=None and start=0.0 are treated the same — it uses the existing time of the event loop. This was historically acceptable since the event loop was function-scoped and created for every test separately in pytest-asyncio<1.0.0.
Since the introduction of multi-scoped event loops in pytest-asyncio>=1.0.0, this assumption is incorrect — (1) the event loop can be reused by many tests; (2) because of this, the starting time of a test is not always zero.
Goal: Separate the behaviour of these values of the start= option as follows:
start=0 means resetting the time of the running event loop to 0, regardless of what it was before the test. If it moves the time backwards because the previous test moved the time forwards, there will be a TimeWarning, which can be converted to an error (an already existing functionality). This is to align it with any other specific value, e.g. start=1 or start=100.
start=None means that the event loop time should not be affected and therefore left "as is". For function-scoped event loops, this is an equivalent of zero. For broader scopes, it will keep the event loop time monotonically growing, which is the expected behaviour of time in event loops shared between multiple tests.
The default should be start=None as the most compatible with the old behaviour in function-scoped tests, and the most expected otherwise.
- Update the docs accordingly.
- Make a test for this case.