MCPcopy
hub / github.com/celery/celery / test_parse_with_timezone

Method test_parse_with_timezone

t/unit/utils/test_time.py:50–65  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

48class test_iso8601:
49
50 def test_parse_with_timezone(self):
51 d = datetime.now(_timezone.utc).replace(tzinfo=ZoneInfo("UTC"))
52 assert parse_iso8601(d.isoformat()) == d
53 # 2013-06-07T20:12:51.775877+00:00
54 iso = d.isoformat()
55 iso1 = iso.replace('+00:00', '-01:00')
56 d1 = parse_iso8601(iso1)
57 d1_offset_in_minutes = d1.utcoffset().total_seconds() / 60
58 assert d1_offset_in_minutes == -60
59 iso2 = iso.replace('+00:00', '+01:00')
60 d2 = parse_iso8601(iso2)
61 d2_offset_in_minutes = d2.utcoffset().total_seconds() / 60
62 assert d2_offset_in_minutes == +60
63 iso3 = iso.replace('+00:00', 'Z')
64 d3 = parse_iso8601(iso3)
65 assert d3.tzinfo == _timezone.utc
66
67
68@pytest.mark.parametrize('delta,expected', [

Callers

nothing calls this directly

Calls 4

parse_iso8601Function · 0.90
replaceMethod · 0.45
nowMethod · 0.45
utcoffsetMethod · 0.45

Tested by

no test coverage detected