MCPcopy
hub / github.com/pallets/flask / test_default_static_max_age

Function test_default_static_max_age

tests/test_blueprints.py:223–244  ·  view source on GitHub ↗
(app)

Source from the content-addressed store, hash-verified

221
222
223def test_default_static_max_age(app):
224 class MyBlueprint(flask.Blueprint):
225 def get_send_file_max_age(self, filename):
226 return 100
227
228 blueprint = MyBlueprint("blueprint", __name__, static_folder="static")
229 app.register_blueprint(blueprint)
230
231 # try/finally, in case other tests use this app for Blueprint tests.
232 max_age_default = app.config["SEND_FILE_MAX_AGE_DEFAULT"]
233 try:
234 with app.test_request_context():
235 unexpected_max_age = 3600
236 if app.config["SEND_FILE_MAX_AGE_DEFAULT"] == unexpected_max_age:
237 unexpected_max_age = 7200
238 app.config["SEND_FILE_MAX_AGE_DEFAULT"] = unexpected_max_age
239 rv = blueprint.send_static_file("index.html")
240 cc = parse_cache_control_header(rv.headers["Cache-Control"])
241 assert cc.max_age == 100
242 rv.close()
243 finally:
244 app.config["SEND_FILE_MAX_AGE_DEFAULT"] = max_age_default
245
246
247def test_templates_list(test_apps):

Callers

nothing calls this directly

Calls 5

MyBlueprintClass · 0.85
test_request_contextMethod · 0.80
closeMethod · 0.80
register_blueprintMethod · 0.45
send_static_fileMethod · 0.45

Tested by

no test coverage detected