MCPcopy Index your code
hub / github.com/RustPython/RustPython / test_bogus_dst

Method test_bogus_dst

Lib/test/datetimetester.py:5806–5831  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 7

okClass · 0.85
notokClass · 0.85
tricky_notokClass · 0.85
nowMethod · 0.80
astimezoneMethod · 0.80
replaceMethod · 0.45
assertRaisesMethod · 0.45

Tested by

no test coverage detected