datetime_ambiguous and datetime_exists agree with the fold offsets.
(tz_source)
| 95 | |
| 96 | |
| 97 | def test_ambiguous_and_imaginary(tz_source): |
| 98 | """datetime_ambiguous and datetime_exists agree with the fold offsets.""" |
| 99 | for key in _keys(): |
| 100 | zone = tz.gettz(key) |
| 101 | for dt_utc in _probe_instants(zone): |
| 102 | local = dt_utc.astimezone(zone).replace(tzinfo=None) |
| 103 | # Local times an hour either side are more likely to land in a |
| 104 | # gap or a fold near a transition. |
| 105 | for wall in ( |
| 106 | local - timedelta(hours=1), |
| 107 | local, |
| 108 | local + timedelta(hours=1), |
| 109 | ): |
| 110 | dt = wall.replace(tzinfo=zone) |
| 111 | offset_0 = tz.enfold(dt, fold=0).utcoffset() |
| 112 | offset_1 = tz.enfold(dt, fold=1).utcoffset() |
| 113 | |
| 114 | case = (key, wall) |
| 115 | assert tz.datetime_ambiguous(dt) == (offset_0 > offset_1), case |
| 116 | assert tz.datetime_exists(dt) == (offset_0 >= offset_1), case |
| 117 | |
| 118 | |
| 119 | def test_matches_zoneinfo(tz_source): |
nothing calls this directly
no test coverage detected