(self)
| 657 | self.assertEqual(dt.dst(), DST.dst) |
| 658 | |
| 659 | def test_no_tz_str(self): |
| 660 | STD = ZoneOffset("STD", ONE_H, ZERO) |
| 661 | DST = ZoneOffset("DST", 2 * ONE_H, ONE_H) |
| 662 | |
| 663 | transitions = [] |
| 664 | for year in range(1996, 2000): |
| 665 | transitions.append( |
| 666 | ZoneTransition(datetime(year, 3, 1, 2), STD, DST) |
| 667 | ) |
| 668 | transitions.append( |
| 669 | ZoneTransition(datetime(year, 11, 1, 2), DST, STD) |
| 670 | ) |
| 671 | |
| 672 | after = "" |
| 673 | |
| 674 | zf = self.construct_zone(transitions, after) |
| 675 | |
| 676 | # According to RFC 8536, local times after the last transition time |
| 677 | # with an empty TZ string are unspecified. We will go with "hold the |
| 678 | # last transition", but the most we should promise is "doesn't crash." |
| 679 | zi = self.klass.from_file(zf) |
| 680 | |
| 681 | cases = [ |
| 682 | (datetime(1995, 1, 1), STD), |
| 683 | (datetime(1996, 4, 1), DST), |
| 684 | (datetime(1996, 11, 2), STD), |
| 685 | (datetime(2001, 1, 1), STD), |
| 686 | ] |
| 687 | |
| 688 | for dt, offset in cases: |
| 689 | dt = dt.replace(tzinfo=zi) |
| 690 | with self.subTest(dt=dt): |
| 691 | self.assertEqual(dt.tzname(), offset.tzname) |
| 692 | self.assertEqual(dt.utcoffset(), offset.utcoffset) |
| 693 | self.assertEqual(dt.dst(), offset.dst) |
| 694 | |
| 695 | # Test that offsets return None when using a datetime.time |
| 696 | t = time(0, tzinfo=zi) |
| 697 | with self.subTest("Testing datetime.time"): |
| 698 | self.assertIs(t.tzname(), None) |
| 699 | self.assertIs(t.utcoffset(), None) |
| 700 | self.assertIs(t.dst(), None) |
| 701 | |
| 702 | def test_tz_before_only(self): |
| 703 | # From RFC 8536 Section 3.2: |
nothing calls this directly
no test coverage detected