Skip to content
Myr

Rewrite test_jsonify_aware_datetimes without pytz

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

authored by Eugene M. Kim · committed by Eugene M. Kim · parent d41e2e6 · Browse files · 2 files+7 added−9 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+7 added−9 removed

  • tests:+7 added−8 removed
  • other:+0 added−1 removed

2 files+7 added−9 removed

modified:tests/test_helpers.py+7 added-8 removed
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 timezone262728def has_encoding(name):29 try:
146 unmodified lines
176 rv = client.get(url)177 assert rv.mimetype == 'application/json'178 assert flask.json.loads(rv.data)['x'] == http_date(d.timetuple())179181 @pytest.mark.parametrize('tzname', ('UTC', 'PST8PDT', 'Asia/Seoul'))182 def test_jsonify_aware_datetimes(self, tzname):180 @pytest.mark.parametrize('tz', (('UTC', 0), ('PST', -8), ('KST', 9)))181 def test_jsonify_aware_datetimes(self, tz):182 """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) == expected183 tzinfo = datetime.timezone(datetime.timedelta(hours=tz[1]), name=tz[0])184 dt = datetime.datetime(2017, 1, 1, 12, 34, 56, tzinfo=tzinfo)185 gmt = datetime.timezone(datetime.timedelta(), name='GMT')186 expected = dt.astimezone(gmt).strftime('"%a, %d %b %Y %H:%M:%S %Z"')187 assert flask.json.JSONEncoder().encode(dt) == expected188189 def test_jsonify_uuid_types(self, app, client):190 """Test jsonify with uuid.UUID types"""191
764 unmodified lines
modified:tox.ini-1 removed
13 unmodified lines
14 pytest>=315 coverage16 greenlet17 blinker18 pytz1819 lowest: Werkzeug==0.920 lowest: Jinja2==2.421 lowest: itsdangerous==0.21
49 unmodified lines