MCPcopy
hub / github.com/pallets/flask / test_jsonify_aware_datetimes

Function test_jsonify_aware_datetimes

tests/test_json.py:167–173  ·  view source on GitHub ↗

Test if aware datetime.datetime objects are converted into GMT.

(tz)

Source from the content-addressed store, hash-verified

165
166@pytest.mark.parametrize("tz", (("UTC", 0), ("PST", -8), ("KST", 9)))
167def test_jsonify_aware_datetimes(tz):
168 """Test if aware datetime.datetime objects are converted into GMT."""
169 tzinfo = FixedOffset(hours=tz[1], name=tz[0])
170 dt = datetime.datetime(2017, 1, 1, 12, 34, 56, tzinfo=tzinfo)
171 gmt = FixedOffset(hours=0, name="GMT")
172 expected = dt.astimezone(gmt).strftime('"%a, %d %b %Y %H:%M:%S %Z"')
173 assert flask.json.dumps(dt) == expected
174
175
176def test_jsonify_uuid_types(app, client):

Callers

nothing calls this directly

Calls 2

FixedOffsetClass · 0.85
dumpsMethod · 0.45

Tested by

no test coverage detected