Skip to content
Myr

Add UTs for #2372

Before adoption: this commit came in with the history the project adopted, so no landing records it.

test_encode_aware_datetime() fails for non-UTC timezones due to the bug.

authored by Eugene M. Kim · committed by Eugene M. Kim · parent 2c97ed9 · Browse files · 2 files+11 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+11 added−0 removed

  • tests:+10 added−0 removed
  • other:+1 added−0 removed

2 files+11 added−0 removed

modified:tests/test_helpers.py+10 added
21 unmodified lines
22from werkzeug.http import parse_cache_control_header, parse_options_header23from werkzeug.http import http_date24from flask._compat import StringIO, text_type25from flask.helpers import get_debug_flag, make_response26from pytz import timezone272829def has_encoding(name):30 try:
146 unmodified lines
177 rv = client.get(url)178 assert rv.mimetype == 'application/json'179 assert flask.json.loads(rv.data)['x'] == http_date(d.timetuple())180181 @pytest.mark.parametrize('tzname', ('UTC', 'PST8PDT', 'Asia/Seoul'))182 def test_jsonify_aware_datetimes(self, tzname):183 """Test if aware datetime.datetime objects are converted into GMT."""184 dt_naive = datetime.datetime(2017, 1, 1, 12, 34, 56)185 dt_aware = timezone(tzname).localize(dt_naive)186 dt_as_gmt = dt_aware.astimezone(timezone('GMT'))187 expected = dt_as_gmt.strftime('"%a, %d %b %Y %H:%M:%S %Z"')188 assert flask.json.JSONEncoder().encode(dt_aware) == expected189190 def test_jsonify_uuid_types(self, app, client):191 """Test jsonify with uuid.UUID types"""192193 test_uuid = uuid.UUID(bytes=b'\xDE\xAD\xBE\xEF' * 4)
763 unmodified lines
modified:tox.ini+1 added
13 unmodified lines
14 pytest>=315 coverage16 greenlet17 blinker18 pytz1920 lowest: Werkzeug==0.921 lowest: Jinja2==2.422 lowest: itsdangerous==0.21
49 unmodified lines