test_templates_and_static() — flask Function Reference
Architecture documentation for the test_templates_and_static() function in test_blueprints.py from the flask codebase.
Entity Profile
Dependency Diagram
graph TD 107a0934_1301_676f_6bde_1dbbefaaf4d1["test_templates_and_static()"] 4366a441_d387_52f9_ec8d_1c41c71c00a8["test_blueprints.py"] 107a0934_1301_676f_6bde_1dbbefaaf4d1 -->|defined in| 4366a441_d387_52f9_ec8d_1c41c71c00a8 style 107a0934_1301_676f_6bde_1dbbefaaf4d1 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_blueprints.py lines 176–220
def test_templates_and_static(test_apps):
from blueprintapp import app
client = app.test_client()
rv = client.get("/")
assert rv.data == b"Hello from the Frontend"
rv = client.get("/admin/")
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()
# try/finally, in case other tests use this app for Blueprint tests.
max_age_default = app.config["SEND_FILE_MAX_AGE_DEFAULT"]
try:
expected_max_age = 3600
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()
finally:
app.config["SEND_FILE_MAX_AGE_DEFAULT"] = max_age_default
with app.test_request_context():
assert (
flask.url_for("admin.static", filename="test.txt")
== "/admin/static/test.txt"
)
with app.test_request_context():
with pytest.raises(TemplateNotFound) as e:
flask.render_template("missing.html")
assert e.value.name == "missing.html"
with flask.Flask(__name__).test_request_context():
assert flask.render_template("nested/nested.txt") == "I'm nested"
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_templates_and_static() do?
test_templates_and_static() is a function in the flask codebase, defined in tests/test_blueprints.py.
Where is test_templates_and_static() defined?
test_templates_and_static() is defined in tests/test_blueprints.py at line 176.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free