test_response_types() — flask Function Reference
Architecture documentation for the test_response_types() function in test_basic.py from the flask codebase.
Entity Profile
Dependency Diagram
graph TD cc2c8544_6a3d_3698_84ec_ba944d9411bf["test_response_types()"] 85bc4fb5_d1d7_a135_020d_69e052c12c0f["test_basic.py"] cc2c8544_6a3d_3698_84ec_ba944d9411bf -->|defined in| 85bc4fb5_d1d7_a135_020d_69e052c12c0f style cc2c8544_6a3d_3698_84ec_ba944d9411bf fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
tests/test_basic.py lines 1122–1213
def test_response_types(app, client):
@app.route("/text")
def from_text():
return "Hällo Wörld"
@app.route("/bytes")
def from_bytes():
return "Hällo Wörld".encode()
@app.route("/full_tuple")
def from_full_tuple():
return (
"Meh",
400,
{"X-Foo": "Testing", "Content-Type": "text/plain; charset=utf-8"},
)
@app.route("/text_headers")
def from_text_headers():
return "Hello", {"X-Foo": "Test", "Content-Type": "text/plain; charset=utf-8"}
@app.route("/text_status")
def from_text_status():
return "Hi, status!", 400
@app.route("/response_headers")
def from_response_headers():
return (
flask.Response(
"Hello world", 404, {"Content-Type": "text/html", "X-Foo": "Baz"}
),
{"Content-Type": "text/plain", "X-Foo": "Bar", "X-Bar": "Foo"},
)
@app.route("/response_status")
def from_response_status():
return app.response_class("Hello world", 400), 500
@app.route("/wsgi")
def from_wsgi():
return NotFound()
@app.route("/dict")
def from_dict():
return {"foo": "bar"}, 201
@app.route("/list")
def from_list():
return ["foo", "bar"], 201
assert client.get("/text").data == "Hällo Wörld".encode()
assert client.get("/bytes").data == "Hällo Wörld".encode()
rv = client.get("/full_tuple")
assert rv.data == b"Meh"
assert rv.headers["X-Foo"] == "Testing"
assert rv.status_code == 400
assert rv.mimetype == "text/plain"
rv = client.get("/text_headers")
assert rv.data == b"Hello"
assert rv.headers["X-Foo"] == "Test"
assert rv.status_code == 200
assert rv.mimetype == "text/plain"
rv = client.get("/text_status")
assert rv.data == b"Hi, status!"
assert rv.status_code == 400
assert rv.mimetype == "text/html"
rv = client.get("/response_headers")
assert rv.data == b"Hello world"
assert rv.content_type == "text/plain"
assert rv.headers.getlist("X-Foo") == ["Bar"]
assert rv.headers["X-Bar"] == "Foo"
assert rv.status_code == 404
rv = client.get("/response_status")
assert rv.data == b"Hello world"
assert rv.status_code == 500
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does test_response_types() do?
test_response_types() is a function in the flask codebase, defined in tests/test_basic.py.
Where is test_response_types() defined?
test_response_types() is defined in tests/test_basic.py at line 1122.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free