From 34af2e2e9a00180ba593e656660e702a35ef2c20 Mon Sep 17 00:00:00 2001 From: Eduardo Apolinario <653394+eapolinario@users.noreply.github.com> Date: Tue, 17 Dec 2024 13:41:27 -0500 Subject: [PATCH] Use the same source of time in flaky test (#3009) * Use the same source of time in flaky test Signed-off-by: Eduardo Apolinario * Use proto Timestamp to get current time Signed-off-by: Eduardo Apolinario --------- Signed-off-by: Eduardo Apolinario Co-authored-by: Eduardo Apolinario --- tests/flytekit/unit/bin/test_python_entrypoint.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/tests/flytekit/unit/bin/test_python_entrypoint.py b/tests/flytekit/unit/bin/test_python_entrypoint.py index bbb33ec962..323770bed7 100644 --- a/tests/flytekit/unit/bin/test_python_entrypoint.py +++ b/tests/flytekit/unit/bin/test_python_entrypoint.py @@ -526,17 +526,20 @@ def test_get_container_error_timestamp(monkeypatch) -> None: assert get_container_error_timestamp(FlyteException("foo", timestamp=10.5)) == Timestamp(seconds=10, nanos=500000000) - current_dtime = datetime.now() + current_timestamp = Timestamp() + current_timestamp.GetCurrentTime() error_timestamp = get_container_error_timestamp(RuntimeError("foo")) - assert error_timestamp.ToDatetime() >= current_dtime + assert error_timestamp.ToDatetime() >= current_timestamp.ToDatetime() - current_dtime = datetime.now() + current_timestamp = Timestamp() + current_timestamp.GetCurrentTime() error_timestamp = get_container_error_timestamp(FlyteException("foo")) - assert error_timestamp.ToDatetime() >= current_dtime + assert error_timestamp.ToDatetime() >= current_timestamp.ToDatetime() - current_dtime = datetime.now() + current_timestamp = Timestamp() + current_timestamp.GetCurrentTime() error_timestamp = get_container_error_timestamp(None) - assert error_timestamp.ToDatetime() >= current_dtime + assert error_timestamp.ToDatetime() >= current_timestamp.ToDatetime() def get_flyte_context(tmp_path_factory, outputs_path):