(self)
| 590 | module = py_zoneinfo |
| 591 | |
| 592 | def test_one_transition(self): |
| 593 | LMT = ZoneOffset("LMT", -timedelta(hours=6, minutes=31, seconds=2)) |
| 594 | STD = ZoneOffset("STD", -timedelta(hours=6)) |
| 595 | |
| 596 | transitions = [ |
| 597 | ZoneTransition(datetime(1883, 6, 9, 14), LMT, STD), |
| 598 | ] |
| 599 | |
| 600 | after = "STD6" |
| 601 | |
| 602 | zf = self.construct_zone(transitions, after) |
| 603 | zi = self.klass.from_file(zf) |
| 604 | |
| 605 | dt0 = datetime(1883, 6, 9, 1, tzinfo=zi) |
| 606 | dt1 = datetime(1883, 6, 10, 1, tzinfo=zi) |
| 607 | |
| 608 | for dt, offset in [(dt0, LMT), (dt1, STD)]: |
| 609 | with self.subTest(name="local", dt=dt): |
| 610 | self.assertEqual(dt.tzname(), offset.tzname) |
| 611 | self.assertEqual(dt.utcoffset(), offset.utcoffset) |
| 612 | self.assertEqual(dt.dst(), offset.dst) |
| 613 | |
| 614 | dts = [ |
| 615 | ( |
| 616 | datetime(1883, 6, 9, 1, tzinfo=zi), |
| 617 | datetime(1883, 6, 9, 7, 31, 2, tzinfo=timezone.utc), |
| 618 | ), |
| 619 | ( |
| 620 | datetime(2010, 4, 1, 12, tzinfo=zi), |
| 621 | datetime(2010, 4, 1, 18, tzinfo=timezone.utc), |
| 622 | ), |
| 623 | ] |
| 624 | |
| 625 | for dt_local, dt_utc in dts: |
| 626 | with self.subTest(name="fromutc", dt=dt_local): |
| 627 | dt_actual = dt_utc.astimezone(zi) |
| 628 | self.assertEqual(dt_actual, dt_local) |
| 629 | |
| 630 | dt_utc_actual = dt_local.astimezone(timezone.utc) |
| 631 | self.assertEqual(dt_utc_actual, dt_utc) |
| 632 | |
| 633 | def test_one_zone_dst(self): |
| 634 | DST = ZoneOffset("DST", ONE_H, ONE_H) |
nothing calls this directly
no test coverage detected