Skip to content

Commit 5771a78

Browse files
authored
Fix test not passing in 32-bit architectures (#2033)
Some architectures cannot hold values after 2038 year. This commit fixes the following tests, adjusting the expiring date for the cookies to a maximum year value of 2037: * test_set_cookie * test_expires_on_set_cookie
1 parent 337ae24 commit 5771a78

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

tests/test_responses.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ def test_file_response_with_inline_disposition(tmpdir, test_client_factory):
293293

294294
def test_set_cookie(test_client_factory, monkeypatch):
295295
# Mock time used as a reference for `Expires` by stdlib `SimpleCookie`.
296-
mocked_now = dt.datetime(2100, 1, 22, 12, 0, 0, tzinfo=dt.timezone.utc)
296+
mocked_now = dt.datetime(2037, 1, 22, 12, 0, 0, tzinfo=dt.timezone.utc)
297297
monkeypatch.setattr(time, "time", lambda: mocked_now.timestamp())
298298

299299
async def app(scope, receive, send):
@@ -316,7 +316,7 @@ async def app(scope, receive, send):
316316
assert response.text == "Hello, world!"
317317
assert (
318318
response.headers["set-cookie"]
319-
== "mycookie=myvalue; Domain=localhost; expires=Fri, 22 Jan 2100 12:00:10 GMT; "
319+
== "mycookie=myvalue; Domain=localhost; expires=Thu, 22 Jan 2037 12:00:10 GMT; "
320320
"HttpOnly; Max-Age=10; Path=/; SameSite=none; Secure"
321321
)
322322

@@ -325,15 +325,15 @@ async def app(scope, receive, send):
325325
"expires",
326326
[
327327
pytest.param(
328-
dt.datetime(2100, 1, 22, 12, 0, 10, tzinfo=dt.timezone.utc), id="datetime"
328+
dt.datetime(2037, 1, 22, 12, 0, 10, tzinfo=dt.timezone.utc), id="datetime"
329329
),
330-
pytest.param("Fri, 22 Jan 2100 12:00:10 GMT", id="str"),
330+
pytest.param("Thu, 22 Jan 2037 12:00:10 GMT", id="str"),
331331
pytest.param(10, id="int"),
332332
],
333333
)
334334
def test_expires_on_set_cookie(test_client_factory, monkeypatch, expires):
335335
# Mock time used as a reference for `Expires` by stdlib `SimpleCookie`.
336-
mocked_now = dt.datetime(2100, 1, 22, 12, 0, 0, tzinfo=dt.timezone.utc)
336+
mocked_now = dt.datetime(2037, 1, 22, 12, 0, 0, tzinfo=dt.timezone.utc)
337337
monkeypatch.setattr(time, "time", lambda: mocked_now.timestamp())
338338

339339
async def app(scope, receive, send):
@@ -344,7 +344,7 @@ async def app(scope, receive, send):
344344
client = test_client_factory(app)
345345
response = client.get("/")
346346
cookie: SimpleCookie = SimpleCookie(response.headers.get("set-cookie"))
347-
assert cookie["mycookie"]["expires"] == "Fri, 22 Jan 2100 12:00:10 GMT"
347+
assert cookie["mycookie"]["expires"] == "Thu, 22 Jan 2037 12:00:10 GMT"
348348

349349

350350
def test_delete_cookie(test_client_factory):

0 commit comments

Comments
 (0)