1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
From: Gard Spreemann <gspr@nonempty.org>
Date: Sat, 25 Feb 2023 16:24:15 +0100
Subject: Dirty, hacky workaround for timing issues in tests
This terrible hack is a workaround to avoid tests randomly failing due
to upstream assuming infinite clock precision. This way we at least
reduce the risk of tests randomly failing.
Of far greater worry is upstream's use of datetime.now as if it were
monotonic [1,2].
[1] https://github.com/optuna/optuna/issues/4455
[2] https://github.com/optuna/optuna/issues/4460
---
tests/storages_tests/test_storages.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/tests/storages_tests/test_storages.py b/tests/storages_tests/test_storages.py
index bf9e3e5..b43e3b3 100644
--- a/tests/storages_tests/test_storages.py
+++ b/tests/storages_tests/test_storages.py
@@ -292,9 +292,9 @@ def test_create_new_trial(storage_mode: str) -> None:
n_trial_in_study = 3
for i in range(n_trial_in_study):
time_before_creation = datetime.now()
- sleep(0.001) # Sleep 1ms to avoid faulty assertion on Windows OS.
+ sleep(0.01)
trial_id = storage.create_new_trial(study_id)
- sleep(0.001)
+ sleep(0.01)
time_after_creation = datetime.now()
trials = storage.get_all_trials(study_id)
|