Fix flaky TestDurations test
TestDurations tests the `--durations=N` functionality which reports N slowest tests, with durations <= 0.005s not shown by default. The test relies on real time.sleep() (in addition to the code which uses time.perf_counter()) which makes it flaky and inconsistent between platforms. Instead of trying to tweak it more, make it use fake time instead. The way it is done is a little hacky but seems to work.
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
import bdb
|
||||
import os
|
||||
import sys
|
||||
from time import perf_counter
|
||||
from time import time
|
||||
from time import perf_counter # Intentionally not `import time` to avoid being
|
||||
from time import time # affected by tests which monkeypatch `time` (issue #185).
|
||||
from typing import Callable
|
||||
from typing import Dict
|
||||
from typing import List
|
||||
|
||||
Reference in New Issue
Block a user