| 2258 | |
| 2259 | @unittest.skipUnless(IS_WIN, "Requires Windows") |
| 2260 | class TzWinLocalTest(unittest.TestCase, TzWinFoldMixin): |
| 2261 | |
| 2262 | def setUp(self): |
| 2263 | self.tzclass = tzwin.tzwinlocal |
| 2264 | self.context = TZWinContext |
| 2265 | |
| 2266 | def get_args(self, tzname): |
| 2267 | return () |
| 2268 | |
| 2269 | def testLocal(self): |
| 2270 | # Not sure how to pin a local time zone, so for now we're just going |
| 2271 | # to run this and make sure it doesn't raise an error |
| 2272 | # See GitHub Issue #135: https://github.com/dateutil/dateutil/issues/135 |
| 2273 | datetime.now(tzwin.tzwinlocal()) |
| 2274 | |
| 2275 | def testTzwinLocalUTCOffset(self): |
| 2276 | with TZWinContext('Eastern Standard Time'): |
| 2277 | tzwl = tzwin.tzwinlocal() |
| 2278 | self.assertEqual(datetime(2014, 3, 11, tzinfo=tzwl).utcoffset(), |
| 2279 | timedelta(hours=-4)) |
| 2280 | |
| 2281 | def testTzwinLocalName(self): |
| 2282 | # https://github.com/dateutil/dateutil/issues/143 |
| 2283 | ESTs = 'Eastern Standard Time' |
| 2284 | EDTs = 'Eastern Daylight Time' |
| 2285 | transition_dates = [(datetime(2015, 3, 8, 0, 59), ESTs), |
| 2286 | (datetime(2015, 3, 8, 3, 1), EDTs), |
| 2287 | (datetime(2015, 11, 1, 0, 59), EDTs), |
| 2288 | (datetime(2015, 11, 1, 3, 1), ESTs), |
| 2289 | (datetime(2016, 3, 13, 0, 59), ESTs), |
| 2290 | (datetime(2016, 3, 13, 3, 1), EDTs), |
| 2291 | (datetime(2016, 11, 6, 0, 59), EDTs), |
| 2292 | (datetime(2016, 11, 6, 3, 1), ESTs)] |
| 2293 | |
| 2294 | with TZWinContext('Eastern Standard Time'): |
| 2295 | tw = tz.tzwinlocal() |
| 2296 | |
| 2297 | for t_date, expected in transition_dates: |
| 2298 | self.assertEqual(t_date.replace(tzinfo=tw).tzname(), expected) |
| 2299 | |
| 2300 | def testTzWinLocalRepr(self): |
| 2301 | tw = tz.tzwinlocal() |
| 2302 | self.assertEqual(repr(tw), 'tzwinlocal()') |
| 2303 | |
| 2304 | def testTzwinLocalRepr(self): |
| 2305 | # https://github.com/dateutil/dateutil/issues/143 |
| 2306 | with TZWinContext('Eastern Standard Time'): |
| 2307 | tw = tz.tzwinlocal() |
| 2308 | |
| 2309 | self.assertEqual(str(tw), 'tzwinlocal(' + |
| 2310 | repr('Eastern Standard Time') + ')') |
| 2311 | |
| 2312 | with TZWinContext('Pacific Standard Time'): |
| 2313 | tw = tz.tzwinlocal() |
| 2314 | |
| 2315 | self.assertEqual(str(tw), 'tzwinlocal(' + |
| 2316 | repr('Pacific Standard Time') + ')') |
| 2317 |
nothing calls this directly
no outgoing calls
no test coverage detected