(self)
| 2689 | # March (M3.2.0) and ends 2 a.m. on first Sunday in November (M11.1.0). |
| 2690 | @support.run_with_tz('EST+05EDT,M3.2.0,M11.1.0') |
| 2691 | def test_timestamp_naive(self): |
| 2692 | t = self.theclass(1970, 1, 1) |
| 2693 | self.assertEqual(t.timestamp(), 18000.0) |
| 2694 | t = self.theclass(1970, 1, 1, 1, 2, 3, 4) |
| 2695 | self.assertEqual(t.timestamp(), |
| 2696 | 18000.0 + 3600 + 2*60 + 3 + 4*1e-6) |
| 2697 | # Missing hour |
| 2698 | t0 = self.theclass(2012, 3, 11, 2, 30) |
| 2699 | t1 = t0.replace(fold=1) |
| 2700 | self.assertEqual(self.theclass.fromtimestamp(t1.timestamp()), |
| 2701 | t0 - timedelta(hours=1)) |
| 2702 | self.assertEqual(self.theclass.fromtimestamp(t0.timestamp()), |
| 2703 | t1 + timedelta(hours=1)) |
| 2704 | # Ambiguous hour defaults to DST |
| 2705 | t = self.theclass(2012, 11, 4, 1, 30) |
| 2706 | self.assertEqual(self.theclass.fromtimestamp(t.timestamp()), t) |
| 2707 | |
| 2708 | # Timestamp may raise an overflow error on some platforms |
| 2709 | # XXX: Do we care to support the first and last year? |
| 2710 | for t in [self.theclass(2,1,1), self.theclass(9998,12,12)]: |
| 2711 | try: |
| 2712 | s = t.timestamp() |
| 2713 | except OverflowError: |
| 2714 | pass |
| 2715 | else: |
| 2716 | self.assertEqual(self.theclass.fromtimestamp(s), t) |
| 2717 | |
| 2718 | def test_timestamp_aware(self): |
| 2719 | t = self.theclass(1970, 1, 1, tzinfo=timezone.utc) |
nothing calls this directly
no test coverage detected