(self)
| 5804 | |
| 5805 | |
| 5806 | def test_bogus_dst(self): |
| 5807 | class ok(tzinfo): |
| 5808 | def utcoffset(self, dt): return HOUR |
| 5809 | def dst(self, dt): return HOUR |
| 5810 | |
| 5811 | now = self.theclass.now().replace(tzinfo=utc_real) |
| 5812 | # Doesn't blow up. |
| 5813 | now.astimezone(ok()) |
| 5814 | |
| 5815 | # Does blow up. |
| 5816 | class notok(ok): |
| 5817 | def dst(self, dt): return None |
| 5818 | self.assertRaises(ValueError, now.astimezone, notok()) |
| 5819 | |
| 5820 | # Sometimes blow up. In the following, tzinfo.dst() |
| 5821 | # implementation may return None or not None depending on |
| 5822 | # whether DST is assumed to be in effect. In this situation, |
| 5823 | # a ValueError should be raised by astimezone(). |
| 5824 | class tricky_notok(ok): |
| 5825 | def dst(self, dt): |
| 5826 | if dt.year == 2000: |
| 5827 | return None |
| 5828 | else: |
| 5829 | return 10*HOUR |
| 5830 | dt = self.theclass(2001, 1, 1).replace(tzinfo=utc_real) |
| 5831 | self.assertRaises(ValueError, dt.astimezone, tricky_notok()) |
| 5832 | |
| 5833 | def test_fromutc(self): |
| 5834 | self.assertRaises(TypeError, Eastern.fromutc) # not enough args |
nothing calls this directly
no test coverage detected