| 2333 | |
| 2334 | @unittest.skipUnless(IS_WIN, "Requires Windows") |
| 2335 | class TzWinLocalTest(unittest.TestCase, TzWinFoldMixin): |
| 2336 | |
| 2337 | def setUp(self): |
| 2338 | self.tzclass = tzwin.tzwinlocal |
| 2339 | self.context = TZWinContext |
| 2340 | |
| 2341 | def get_args(self, tzname): |
| 2342 | return () |
| 2343 | |
| 2344 | def testLocal(self): |
| 2345 | # Not sure how to pin a local time zone, so for now we're just going |
| 2346 | # to run this and make sure it doesn't raise an error |
| 2347 | # See GitHub Issue #135: https://github.com/dateutil/dateutil/issues/135 |
| 2348 | datetime.now(tzwin.tzwinlocal()) |
| 2349 | |
| 2350 | def testTzwinLocalUTCOffset(self): |
| 2351 | with TZWinContext('Eastern Standard Time'): |
| 2352 | tzwl = tzwin.tzwinlocal() |
| 2353 | self.assertEqual(datetime(2014, 3, 11, tzinfo=tzwl).utcoffset(), |
| 2354 | timedelta(hours=-4)) |
| 2355 | |
| 2356 | def testTzwinLocalName(self): |
| 2357 | # https://github.com/dateutil/dateutil/issues/143 |
| 2358 | ESTs = 'Eastern Standard Time' |
| 2359 | EDTs = 'Eastern Daylight Time' |
| 2360 | transition_dates = [(datetime(2015, 3, 8, 0, 59), ESTs), |
| 2361 | (datetime(2015, 3, 8, 3, 1), EDTs), |
| 2362 | (datetime(2015, 11, 1, 0, 59), EDTs), |
| 2363 | (datetime(2015, 11, 1, 3, 1), ESTs), |
| 2364 | (datetime(2016, 3, 13, 0, 59), ESTs), |
| 2365 | (datetime(2016, 3, 13, 3, 1), EDTs), |
| 2366 | (datetime(2016, 11, 6, 0, 59), EDTs), |
| 2367 | (datetime(2016, 11, 6, 3, 1), ESTs)] |
| 2368 | |
| 2369 | with TZWinContext('Eastern Standard Time'): |
| 2370 | tw = tz.tzwinlocal() |
| 2371 | |
| 2372 | for t_date, expected in transition_dates: |
| 2373 | self.assertEqual(t_date.replace(tzinfo=tw).tzname(), expected) |
| 2374 | |
| 2375 | def testTzWinLocalRepr(self): |
| 2376 | tw = tz.tzwinlocal() |
| 2377 | self.assertEqual(repr(tw), 'tzwinlocal()') |
| 2378 | |
| 2379 | def testTzwinLocalRepr(self): |
| 2380 | # https://github.com/dateutil/dateutil/issues/143 |
| 2381 | with TZWinContext('Eastern Standard Time'): |
| 2382 | tw = tz.tzwinlocal() |
| 2383 | |
| 2384 | self.assertEqual(str(tw), 'tzwinlocal(' + |
| 2385 | repr('Eastern Standard Time') + ')') |
| 2386 | |
| 2387 | with TZWinContext('Pacific Standard Time'): |
| 2388 | tw = tz.tzwinlocal() |
| 2389 | |
| 2390 | self.assertEqual(str(tw), 'tzwinlocal(' + |
| 2391 | repr('Pacific Standard Time') + ')') |
| 2392 |
nothing calls this directly
no outgoing calls
no test coverage detected