(self)
| 2640 | # March (M3.2.0) and ends 2 a.m. on first Sunday in November (M11.1.0). |
| 2641 | @support.run_with_tz('EST+05EDT,M3.2.0,M11.1.0') |
| 2642 | def test_timestamp_naive(self): |
| 2643 | t = self.theclass(1970, 1, 1) |
| 2644 | self.assertEqual(t.timestamp(), 18000.0) |
| 2645 | t = self.theclass(1970, 1, 1, 1, 2, 3, 4) |
| 2646 | self.assertEqual(t.timestamp(), |
| 2647 | 18000.0 + 3600 + 2*60 + 3 + 4*1e-6) |
| 2648 | # Missing hour |
| 2649 | t0 = self.theclass(2012, 3, 11, 2, 30) |
| 2650 | t1 = t0.replace(fold=1) |
| 2651 | self.assertEqual(self.theclass.fromtimestamp(t1.timestamp()), |
| 2652 | t0 - timedelta(hours=1)) |
| 2653 | self.assertEqual(self.theclass.fromtimestamp(t0.timestamp()), |
| 2654 | t1 + timedelta(hours=1)) |
| 2655 | # Ambiguous hour defaults to DST |
| 2656 | t = self.theclass(2012, 11, 4, 1, 30) |
| 2657 | self.assertEqual(self.theclass.fromtimestamp(t.timestamp()), t) |
| 2658 | |
| 2659 | # Timestamp may raise an overflow error on some platforms |
| 2660 | # XXX: Do we care to support the first and last year? |
| 2661 | for t in [self.theclass(2,1,1), self.theclass(9998,12,12)]: |
| 2662 | try: |
| 2663 | s = t.timestamp() |
| 2664 | except OverflowError: |
| 2665 | pass |
| 2666 | else: |
| 2667 | self.assertEqual(self.theclass.fromtimestamp(s), t) |
| 2668 | |
| 2669 | def test_timestamp_aware(self): |
| 2670 | t = self.theclass(1970, 1, 1, tzinfo=timezone.utc) |
nothing calls this directly
no test coverage detected