test_static_file() — flask Function Reference
Architecture documentation for the test_static_file() function in test_helpers.py from the flask codebase.
Entity Profile
Dependency Diagram
graph TD ff2bf99f_2463_5326_ac14_ae01b07f58b2["test_static_file()"] b3e863f6_458a_708a_dfc2_28e32b43300e["TestSendfile"] ff2bf99f_2463_5326_ac14_ae01b07f58b2 -->|defined in| b3e863f6_458a_708a_dfc2_28e32b43300e aeed6e85_d75e_4caa_702e_8017da7792a4["close()"] ff2bf99f_2463_5326_ac14_ae01b07f58b2 -->|calls| aeed6e85_d75e_4caa_702e_8017da7792a4 c8f25f17_033b_8930_263e_90e79b214811["get_send_file_max_age()"] ff2bf99f_2463_5326_ac14_ae01b07f58b2 -->|calls| c8f25f17_033b_8930_263e_90e79b214811 style ff2bf99f_2463_5326_ac14_ae01b07f58b2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_helpers.py lines 45–90
def test_static_file(self, app, req_ctx):
# Default max_age is None.
# Test with static file handler.
rv = app.send_static_file("index.html")
assert rv.cache_control.max_age is None
rv.close()
# Test with direct use of send_file.
rv = flask.send_file("static/index.html")
assert rv.cache_control.max_age is None
rv.close()
app.config["SEND_FILE_MAX_AGE_DEFAULT"] = 3600
# Test with static file handler.
rv = app.send_static_file("index.html")
assert rv.cache_control.max_age == 3600
rv.close()
# Test with direct use of send_file.
rv = flask.send_file("static/index.html")
assert rv.cache_control.max_age == 3600
rv.close()
# Test with pathlib.Path.
rv = app.send_static_file(FakePath("index.html"))
assert rv.cache_control.max_age == 3600
rv.close()
class StaticFileApp(flask.Flask):
def get_send_file_max_age(self, filename):
return 10
app = StaticFileApp(__name__)
with app.test_request_context():
# Test with static file handler.
rv = app.send_static_file("index.html")
assert rv.cache_control.max_age == 10
rv.close()
# Test with direct use of send_file.
rv = flask.send_file("static/index.html")
assert rv.cache_control.max_age == 10
rv.close()
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_static_file() do?
test_static_file() is a function in the flask codebase, defined in tests/test_helpers.py.
Where is test_static_file() defined?
test_static_file() is defined in tests/test_helpers.py at line 45.
What does test_static_file() call?
test_static_file() calls 2 function(s): close, get_send_file_max_age.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free