update json.dumps for http_date changes

This commit is contained in:
Grey Li 2021-02-25 09:42:44 -08:00 committed by David Lord
parent dcd3b5c8f8
commit 49b7341a49
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
3 changed files with 12 additions and 17 deletions

View file

@ -129,19 +129,16 @@ def test_jsonify_arrays(app, client):
assert flask.json.loads(rv.data) == a_list
def test_jsonifytypes(app, client):
"""Test jsonify with datetime.date and datetime.datetime types."""
test_dates = (
datetime.datetime(1973, 3, 11, 6, 30, 45),
datetime.date(1975, 1, 5),
)
@pytest.mark.parametrize(
"value", [datetime.datetime(1973, 3, 11, 6, 30, 45), datetime.date(1975, 1, 5)]
)
def test_jsonify_datetime(app, client, value):
@app.route("/")
def index():
return flask.jsonify(value=value)
for i, d in enumerate(test_dates):
url = f"/datetest{i}"
app.add_url_rule(url, str(i), lambda val=d: flask.jsonify(x=val))
rv = client.get(url)
assert rv.mimetype == "application/json"
assert flask.json.loads(rv.data)["x"] == http_date(d.timetuple())
r = client.get()
assert r.json["value"] == http_date(value)
class FixedOffset(datetime.tzinfo):