11from datetime import datetime , timedelta # noqa: INP001
22
3- import pytz
4- from pytz import timezone
3+ from pytz import UTC , timezone
54
65
76def test_flight_time () -> None :
@@ -29,8 +28,8 @@ def test_flight_time() -> None:
2928 arrival_local = tz_bangkok .localize (arrival_date )
3029
3130 # Convert both times to UTC for comparison
32- departure_utc = departure_local .astimezone (pytz . UTC )
33- arrival_utc = arrival_local .astimezone (pytz . UTC )
31+ departure_utc = departure_local .astimezone (UTC )
32+ arrival_utc = arrival_local .astimezone (UTC )
3433
3534 # Check UTC times
3635 assert departure_utc
@@ -51,17 +50,17 @@ def test_flight_time() -> None:
5150
5251 # Calculate offset difference in hours
5352 tz_diff_hours = bangkok_offset - zurich_offset
54- assert (
55- tz_diff_hours == expected_tz_difference
56- ), f"Unexpected TZ difference, exected { expected_tz_difference } got { tz_diff_hours } "
53+ assert tz_diff_hours == expected_tz_difference , (
54+ f"Unexpected TZ difference: found { expected_tz_difference } got { tz_diff_hours } "
55+ )
5756
5857 # 2. Check the expected flight time
5958 # Calculate actual flight duration
6059 flight_duration = arrival_utc - departure_utc
6160 flight_hours = flight_duration .total_seconds () / 3600.0
62- assert (
63- abs ( flight_hours - expected_flight_hours ) < 0.0001
64- ), f"Expected flight time ~ { expected_flight_hours } h, got { flight_hours :.2f } h"
61+ assert abs ( flight_hours - expected_flight_hours ) < 0.0001 , (
62+ f"Expected flight time ~ { expected_flight_hours } h, got { flight_hours :.2f } h"
63+ )
6564
6665 # 3. Check that the arrival time equals departure time + flight duration
6766 # Add the expected flight time to the departure time and compare to arrival time
0 commit comments