You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
All the test_files tests are failing for both asgi and wsgi in the case for "if-modified-since" header. Other header scenarios are passing with a valid 304 being returned but this particular one returns a 200 for some reason
_______________________________ test_files[app0] _______________________________
app = <baize.wsgi.staticfiles.Files object at 0x1f80642fbd0>
@pytest.mark.parametrize(
"app",
[
Files(Path(__file__).absolute().parent.parent / "baize"),
Files(".", "baize"),
Files(".", "baize", handle_404=PlainTextResponse("", 404)),
],
)
def test_files(app):
with httpx.Client(app=app, base_url="http://testServer/") as client:
resp = client.get("/py.typed")
assert resp.text == ""
assert (
client.get("/py.typed", headers={"if-none-match": resp.headers["etag"]})
).status_code == 304
assert (
client.get(
"/py.typed", headers={"if-none-match": "W/" + resp.headers["etag"]}
)
).status_code == 304
assert (
client.get("/py.typed", headers={"if-none-match": "*"})
).status_code == 304
> assert (
client.get(
"/py.typed",
headers={"if-modified-since": resp.headers["last-modified"]},
)
).status_code == 304
E AssertionError: assert 200 == 304
E + where 200 = <Response [200 OK]>.status_code
E + where <Response [200 OK]> = <bound method Client.get of <httpx.Client object at 0x1f7b018f4d0>>('/py.typed', headers={'if-modified-since': 'Fri, 26 Jul 2024 15:42:11 GMT'})
E + where <bound method Client.get of <httpx.Client object at 0x1f7b018f4d0>> = <httpx.Client object at 0x1f7b018f4d0>.get
tests/test_wsgi.py:641: AssertionError
The text was updated successfully, but these errors were encountered:
Seems like the solution is to use st_mtime instead of st_ctime as the response header uses st_mtime in the original response but for some reason the comparison for the if-modified-since uses the st_ctime. st_ctime is changed even when you change permissions of the file, which isn't something that you would normally want to care about for the http response.
All the test_files tests are failing for both asgi and wsgi in the case for "if-modified-since" header. Other header scenarios are passing with a valid 304 being returned but this particular one returns a 200 for some reason
The text was updated successfully, but these errors were encountered: