def test_bogus_dst(self):
class ok(tzinfo):
def utcoffset(self, dt): return HOUR
def dst(self, dt): return HOUR
now = self.theclass.now().replace(tzinfo=utc_real)
# Doesn't blow up.
now.astimezone(ok())
# Does blow up.
class notok(ok):
def dst(self, dt): return None
self.assertRaises(ValueError, now.astimezone, notok())
# Sometimes blow up. In the following, tzinfo.dst()
# implementation may return None or not None depending on
# whether DST is assumed to be in effect. In this situation,
# a ValueError should be raised by astimezone().
class tricky_notok(ok):
def dst(self, dt):
if dt.year == 2000:
return None
else:
return 10*HOUR
dt = self.theclass(2001, 1, 1).replace(tzinfo=utc_real)
self.assertRaises(ValueError, dt.astimezone, tricky_notok())
评论列表
文章目录