From d02fef34e9550a686d69a44f7b98f09a42a5d35c Mon Sep 17 00:00:00 2001 From: Ma Lu Date: Tue, 29 Oct 2024 15:57:31 +0100 Subject: [PATCH] blacked --- logprep/util/time.py | 6 +++++- tests/unit/util/test_time.py | 8 ++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/logprep/util/time.py b/logprep/util/time.py index 4a01f5894..66046ca22 100644 --- a/logprep/util/time.py +++ b/logprep/util/time.py @@ -134,7 +134,11 @@ def parse_datetime( The parsed timestamp as datetime object. """ if source_format == "UNIX": - parsed_datetime = int(timestamp) if len(timestamp) <= 10 else int(timestamp) / 10 ** (len(timestamp) - 10) + parsed_datetime = ( + int(timestamp) + if len(timestamp) <= 10 + else int(timestamp) / 10 ** (len(timestamp) - 10) + ) parsed_datetime = cls.from_timestamp(parsed_datetime) elif source_format == "ISO8601": parsed_datetime = cls.from_string(timestamp, set_missing_utc=False) diff --git a/tests/unit/util/test_time.py b/tests/unit/util/test_time.py index f8d93d8fc..4599f6fda 100644 --- a/tests/unit/util/test_time.py +++ b/tests/unit/util/test_time.py @@ -168,22 +168,22 @@ def test_parse_datetime_unix_timestamp_is_always_utc( assert timestamp.tzinfo.tzname(timestamp) == expected_timezone_name for attribute, value in expected.items(): assert getattr(timestamp, attribute) == value - + @pytest.mark.parametrize( "timestamp, expected_timezone_name, expected", [ ( - "1615634593", + "1615634593", "UTC", {"year": 2021, "month": 3, "day": 13, "hour": 11, "minute": 23, "second": 13}, ), ( - "1615634593000", + "1615634593000", "UTC", {"year": 2021, "month": 3, "day": 13, "hour": 11, "minute": 23, "second": 13}, ), ( - "1615634593000000", + "1615634593000000", "UTC", {"year": 2021, "month": 3, "day": 13, "hour": 11, "minute": 23, "second": 13}, ),