Skip to content
Myr

Re-revert to not using pytz

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

Will spin a tzinfo subclass.

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

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

2 files+7 added−15 removed

modified:tests/test_helpers.py+7 added-14 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_response26try:27 from pytz import timezone28except ImportError:29 has_pytz = False30else:31 has_pytz = True262728def 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())179186 @pytest.mark.skipif('not has_pytz')187 @pytest.mark.parametrize('tzname', ('UTC', 'PST8PDT', 'Asia/Seoul'))188 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."""190 dt_naive = datetime.datetime(2017, 1, 1, 12, 34, 56)191 dt_aware = timezone(tzname).localize(dt_naive)192 dt_as_gmt = dt_aware.astimezone(timezone('GMT'))193 expected = dt_as_gmt.strftime('"%a, %d %b %Y %H:%M:%S %Z"')194 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