MCPcopy Index your code
hub / github.com/python/cpython / test_bogus_dst

Method test_bogus_dst

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

Source from the content-addressed store, hash-verified

5991
5992
5993 def test_bogus_dst(self):
5994 class ok(tzinfo):
5995 def utcoffset(self, dt): return HOUR
5996 def dst(self, dt): return HOUR
5997
5998 now = self.theclass.now().replace(tzinfo=utc_real)
5999 # Doesn't blow up.
6000 now.astimezone(ok())
6001
6002 # Does blow up.
6003 class notok(ok):
6004 def dst(self, dt): return None
6005 self.assertRaises(ValueError, now.astimezone, notok())
6006
6007 # Sometimes blow up. In the following, tzinfo.dst()
6008 # implementation may return None or not None depending on
6009 # whether DST is assumed to be in effect. In this situation,
6010 # a ValueError should be raised by astimezone().
6011 class tricky_notok(ok):
6012 def dst(self, dt):
6013 if dt.year == 2000:
6014 return None
6015 else:
6016 return 10*HOUR
6017 dt = self.theclass(2001, 1, 1).replace(tzinfo=utc_real)
6018 self.assertRaises(ValueError, dt.astimezone, tricky_notok())
6019
6020 def test_fromutc(self):
6021 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