Skip to content

Commit 716ee0d

Browse files
committed
Use year 2100 in tests instead of 3030 to avoid Windows datetime limits
1 parent 041c8b6 commit 716ee0d

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

tests/functional/test_uploaded_prior_to.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ def test_uploaded_prior_to_file_index_no_upload_time(
3333
"install",
3434
"--index-url",
3535
data.index_url("simple"),
36-
"--uploaded-prior-to=3030-01-01T00:00:00",
36+
"--uploaded-prior-to=2100-01-01T00:00:00",
3737
"simple",
3838
expect_error=False,
3939
)
@@ -55,7 +55,7 @@ def test_uploaded_prior_to_http_index_no_upload_time(
5555
"install",
5656
"--index-url",
5757
f"http://{server.host}:{server.port}",
58-
"--uploaded-prior-to=3030-01-01T00:00:00",
58+
"--uploaded-prior-to=2100-01-01T00:00:00",
5959
"simple",
6060
expect_error=True,
6161
)

tests/unit/test_cmdoptions.py

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def test_handle_uploaded_prior_to_naive_dates(
120120
# Check that local timezone was applied (result should not be timezone-naive)
121121
assert result.tzinfo is not None
122122

123-
# Verify it's equivalent to creating the same datetime and applying local timezone
123+
# Verify it's equivalent to what .astimezone() produces on a naive datetime
124124
naive_dt = datetime.datetime(*expected_date_time)
125125
expected_with_local_tz = naive_dt.astimezone()
126126
assert result == expected_with_local_tz
@@ -145,3 +145,33 @@ def test_handle_uploaded_prior_to_invalid_dates(invalid_value: str) -> None:
145145

146146
with pytest.raises(SystemExit):
147147
_handle_uploaded_prior_to(option, opt, invalid_value, parser)
148+
149+
150+
def test_handle_uploaded_prior_to_naive() -> None:
151+
"""
152+
Test that a naive datetime is interpreted as local time.
153+
"""
154+
option = Option("--uploaded-prior-to", dest="uploaded_prior_to")
155+
opt = "--uploaded-prior-to"
156+
parser = OptionParser()
157+
parser.values = Values()
158+
159+
# Parse a naive datetime
160+
naive_input = "2023-06-15T14:30:00"
161+
_handle_uploaded_prior_to(option, opt, naive_input, parser)
162+
result = parser.values.uploaded_prior_to
163+
164+
assert result.hour == 14, (
165+
f"Expected hour=14 (from input), got hour={result.hour}. "
166+
"This suggests the naive datetime was incorrectly interpreted as UTC "
167+
"and converted to local timezone."
168+
)
169+
assert result.minute == 30
170+
assert result.year == 2023
171+
assert result.month == 6
172+
assert result.day == 15
173+
174+
# Verify by creating the same datetime with explicit local timezone
175+
local_tz = datetime.datetime.now().astimezone().tzinfo
176+
expected = datetime.datetime(2023, 6, 15, 14, 30, 0, tzinfo=local_tz)
177+
assert result == expected

0 commit comments

Comments
 (0)