Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use in_timezone parameter to make pytz and others work the same #3

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/icalendar/tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ def events():
def utc(request):
return request.param

@pytest.fixture(params=[pytz.timezone, tz.gettz, zoneinfo.ZoneInfo])
def timezone(request):
@pytest.fixture(params=[
lambda dt, tzname: pytz.timezone(tzname).localize(dt),
lambda dt, tzname: dt.replace(tzinfo=tz.gettz(tzname)),
lambda dt, tzname: dt.replace(tzinfo=zoneinfo.ZoneInfo(tzname))
])
def in_timezone(request):
return request.param
4 changes: 2 additions & 2 deletions src/icalendar/tests/test_encoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ def test_events_unicoded(events, event_name):
event = getattr(events, event_name)
assert event.to_ical() == event.raw_ics

def test_parses_event_with_non_ascii_tzid_issue_237(calendars, timezone):
def test_parses_event_with_non_ascii_tzid_issue_237(calendars, in_timezone):
"""Issue #237 - Fail to parse timezone with non-ascii TZID
see https://github.com/collective/icalendar/issues/237
"""
start = calendars.issue_237_fail_to_parse_timezone_with_non_ascii_tzid.walk('VEVENT')[0].decoded('DTSTART')
expected = datetime.datetime(2017, 5, 11, 13, 30, tzinfo=timezone('America/Sao_Paulo'))
expected = in_timezone(datetime.datetime(2017, 5, 11, 13, 30), 'America/Sao_Paulo')
assert start == expected

def test_parses_timezone_with_non_ascii_tzid_issue_237(timezones):
Expand Down