Skip to content

Commit 703cdc4

Browse files
committed
Improve parameter formatting of test_handle_exclude_newer_than_with_timezone
1 parent fbe923d commit 703cdc4

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

tests/unit/test_cmdoptions.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import datetime
44
import os
5-
from collections.abc import Callable
65
from optparse import Option, OptionParser, Values
76
from pathlib import Path
87
from venv import EnvBuilder
@@ -60,28 +59,23 @@ def test_identify_python_interpreter_venv(tmpdir: Path) -> None:
6059

6160

6261
@pytest.mark.parametrize(
63-
"value, expected_check",
62+
"value, expected_datetime",
6463
[
65-
# Test with timezone info (should be preserved exactly)
6664
(
6765
"2023-01-01T00:00:00+00:00",
68-
lambda dt: dt
69-
== datetime.datetime(2023, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc),
66+
datetime.datetime(2023, 1, 1, 0, 0, 0, tzinfo=datetime.timezone.utc),
7067
),
7168
(
7269
"2023-01-01T12:00:00-05:00",
73-
lambda dt: (
74-
dt
75-
== datetime.datetime(
76-
*(2023, 1, 1, 12, 0, 0),
77-
tzinfo=datetime.timezone(datetime.timedelta(hours=-5)),
78-
)
70+
datetime.datetime(
71+
*(2023, 1, 1, 12, 0, 0),
72+
tzinfo=datetime.timezone(datetime.timedelta(hours=-5)),
7973
),
8074
),
8175
],
8276
)
8377
def test_handle_exclude_newer_than_with_timezone(
84-
value: str, expected_check: Callable[[datetime.datetime], bool]
78+
value: str, expected_datetime: datetime.datetime
8579
) -> None:
8680
"""Test that timezone-aware ISO 8601 date strings are parsed correctly."""
8781
option = Option("--exclude-newer-than", dest="exclude_newer_than")
@@ -93,7 +87,7 @@ def test_handle_exclude_newer_than_with_timezone(
9387

9488
result = parser.values.exclude_newer_than
9589
assert isinstance(result, datetime.datetime)
96-
assert expected_check(result)
90+
assert result == expected_datetime
9791

9892

9993
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)