From 152e07f3e3948d7db7be18a462442fee015a6c7e Mon Sep 17 00:00:00 2001 From: mao3267 Date: Mon, 25 Nov 2024 22:27:55 +0800 Subject: [PATCH] fix: set timezone to utc Signed-off-by: mao3267 --- tests/flytekit/unit/bin/test_python_entrypoint.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tests/flytekit/unit/bin/test_python_entrypoint.py b/tests/flytekit/unit/bin/test_python_entrypoint.py index 3955019cd0..bbb33ec962 100644 --- a/tests/flytekit/unit/bin/test_python_entrypoint.py +++ b/tests/flytekit/unit/bin/test_python_entrypoint.py @@ -518,7 +518,12 @@ def test_get_traceback_str(): assert expected_error_re.match(traceback_str) is not None -def test_get_container_error_timestamp() -> None: +def test_get_container_error_timestamp(monkeypatch) -> None: + # Set the timezone to UTC + monkeypatch.setenv("TZ", "UTC") + if hasattr(time, 'tzset'): + time.tzset() + assert get_container_error_timestamp(FlyteException("foo", timestamp=10.5)) == Timestamp(seconds=10, nanos=500000000) current_dtime = datetime.now()