Support returning list as JSON

This commit is contained in:
Grey Li 2022-07-02 10:39:18 +08:00 committed by David Lord
parent 1626aff602
commit ca2bfbb0ac
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
3 changed files with 16 additions and 4 deletions

View file

@ -1166,6 +1166,10 @@ def test_response_types(app, client):
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()
@ -1205,6 +1209,10 @@ def test_response_types(app, client):
assert rv.json == {"foo": "bar"}
assert rv.status_code == 201
rv = client.get("/list")
assert rv.json == ["foo", "bar"]
assert rv.status_code == 201
def test_response_type_errors():
app = flask.Flask(__name__)