mirror of
https://github.com/Akkudoktor-EOS/EOS.git
synced 2026-07-21 17:28:11 +00:00
fix(test): flaky test_datetimutil test case TC026 (#1158)
This fix was taken from https://github.com/arneman/EOS/tree/refactor/economic-objective. Avoid flaky TC026 by comparing timestamps at assertion time. Signed-off-by: Bobby Noelte <b0661n0e17e@gmail.com>
This commit is contained in:
@@ -1204,7 +1204,11 @@ def test_to_datetime(
|
||||
# print(f"Result: {result} tz={result.timezone}")
|
||||
# print(f"Compare: {compare}")
|
||||
if expected_approximately:
|
||||
assert compare.time_diff < 300
|
||||
# Compare using Unix timestamps to avoid pendulum timezone state
|
||||
# issues and to prevent staleness from parametrize collection time.
|
||||
import time
|
||||
|
||||
assert abs(result.timestamp() - time.time()) < 300
|
||||
else:
|
||||
assert compare.equal == True
|
||||
|
||||
|
||||
Reference in New Issue
Block a user