all teardown callbacks are called despite errors

This commit is contained in:
David Lord 2026-02-19 19:41:50 -08:00
parent 7b0088693e
commit fbb6f0bc4c
No known key found for this signature in database
GPG key ID: 43368A7AA8CC5926
10 changed files with 195 additions and 81 deletions

View file

@ -184,12 +184,12 @@ def test_templates_and_static(test_apps):
assert rv.data == b"Hello from the Admin"
rv = client.get("/admin/index2")
assert rv.data == b"Hello from the Admin"
rv = client.get("/admin/static/test.txt")
assert rv.data.strip() == b"Admin File"
rv.close()
rv = client.get("/admin/static/css/test.css")
assert rv.data.strip() == b"/* nested file */"
rv.close()
with client.get("/admin/static/test.txt") as rv:
assert rv.data.strip() == b"Admin File"
with client.get("/admin/static/css/test.css") as rv:
assert rv.data.strip() == b"/* nested file */"
# try/finally, in case other tests use this app for Blueprint tests.
max_age_default = app.config["SEND_FILE_MAX_AGE_DEFAULT"]
@ -198,10 +198,10 @@ def test_templates_and_static(test_apps):
if app.config["SEND_FILE_MAX_AGE_DEFAULT"] == expected_max_age:
expected_max_age = 7200
app.config["SEND_FILE_MAX_AGE_DEFAULT"] = expected_max_age
rv = client.get("/admin/static/css/test.css")
cc = parse_cache_control_header(rv.headers["Cache-Control"])
assert cc.max_age == expected_max_age
rv.close()
with client.get("/admin/static/css/test.css") as rv:
cc = parse_cache_control_header(rv.headers["Cache-Control"])
assert cc.max_age == expected_max_age
finally:
app.config["SEND_FILE_MAX_AGE_DEFAULT"] = max_age_default