MCPcopy Create free account
hub / github.com/dateutil/dateutil / test_dst_inference

Function test_dst_inference

tests/test_tzfile.py:2772–2783  ·  view source on GitHub ↗

dst() is inferred from the standard time around each DST period.

(transitions, expected)

Source from the content-addressed store, hash-verified

2770
2771@pytest.mark.parametrize("transitions, expected", _dst_inference_cases())
2772def test_dst_inference(transitions, expected):
2773 """dst() is inferred from the standard time around each DST period."""
2774 zone = tz.tzfile(construct_zone(transitions))
2775
2776 for dt_utc, dst in expected:
2777 dt = dt_utc.replace(tzinfo=tz.UTC).astimezone(zone)
2778 assert dt.dst() == dst, dt_utc
2779 assert dt.replace(tzinfo=None).replace(tzinfo=zone).dst() == dst
2780
2781 # The pickled data is the data from the file, so the inference gives the
2782 # same answers after a round trip
2783 assert pickle.loads(pickle.dumps(zone)) == zone
2784
2785
2786####

Callers

nothing calls this directly

Calls 3

construct_zoneFunction · 0.85
replaceMethod · 0.80
dstMethod · 0.45

Tested by

no test coverage detected