(self)
| 5226 | self.assertRaises(TypeError, meth, ts, tzinfo=off42) |
| 5227 | |
| 5228 | def test_tzinfo_timetuple(self): |
| 5229 | # TestDateTime tested most of this. datetime adds a twist to the |
| 5230 | # DST flag. |
| 5231 | class DST(tzinfo): |
| 5232 | def __init__(self, dstvalue): |
| 5233 | if isinstance(dstvalue, int): |
| 5234 | dstvalue = timedelta(minutes=dstvalue) |
| 5235 | self.dstvalue = dstvalue |
| 5236 | def dst(self, dt): |
| 5237 | return self.dstvalue |
| 5238 | |
| 5239 | cls = self.theclass |
| 5240 | for dstvalue, flag in (-33, 1), (33, 1), (0, 0), (None, -1): |
| 5241 | d = cls(1, 1, 1, 10, 20, 30, 40, tzinfo=DST(dstvalue)) |
| 5242 | t = d.timetuple() |
| 5243 | self.assertEqual(1, t.tm_year) |
| 5244 | self.assertEqual(1, t.tm_mon) |
| 5245 | self.assertEqual(1, t.tm_mday) |
| 5246 | self.assertEqual(10, t.tm_hour) |
| 5247 | self.assertEqual(20, t.tm_min) |
| 5248 | self.assertEqual(30, t.tm_sec) |
| 5249 | self.assertEqual(0, t.tm_wday) |
| 5250 | self.assertEqual(1, t.tm_yday) |
| 5251 | self.assertEqual(flag, t.tm_isdst) |
| 5252 | |
| 5253 | # dst() returns wrong type. |
| 5254 | self.assertRaises(TypeError, cls(1, 1, 1, tzinfo=DST("x")).timetuple) |
| 5255 | |
| 5256 | # dst() at the edge. |
| 5257 | self.assertEqual(cls(1,1,1, tzinfo=DST(1439)).timetuple().tm_isdst, 1) |
| 5258 | self.assertEqual(cls(1,1,1, tzinfo=DST(-1439)).timetuple().tm_isdst, 1) |
| 5259 | |
| 5260 | # dst() out of range. |
| 5261 | self.assertRaises(ValueError, cls(1,1,1, tzinfo=DST(1440)).timetuple) |
| 5262 | self.assertRaises(ValueError, cls(1,1,1, tzinfo=DST(-1440)).timetuple) |
| 5263 | |
| 5264 | def test_utctimetuple(self): |
| 5265 | class DST(tzinfo): |
nothing calls this directly
no test coverage detected