MCPcopy Create free account
hub / github.com/dateutil/dateutil / TZStrTest

Class TZStrTest

tests/test_tz.py:1483–1600  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1481
1482@pytest.mark.tzstr
1483class TZStrTest(unittest.TestCase, TzFoldMixin):
1484 # POSIX string indicating change to summer time on the 2nd Sunday in March
1485 # at 2AM, and ending the 1st Sunday in November at 2AM. (valid >= 2007)
1486 TZ_EST = 'EST+5EDT,M3.2.0/2,M11.1.0/2'
1487
1488 # POSIX string for AEST/AEDT (valid >= 2008)
1489 TZ_AEST = 'AEST-10AEDT,M10.1.0/2,M4.1.0/3'
1490
1491 # POSIX string for GMT/BST
1492 TZ_LON = 'GMT0BST,M3.5.0,M10.5.0'
1493
1494 def gettz(self, tzname):
1495 # Actual time zone changes are handled by the _gettz_context function
1496 tzname_map = {'Australia/Sydney': self.TZ_AEST,
1497 'America/Toronto': self.TZ_EST,
1498 'America/New_York': self.TZ_EST,
1499 'Europe/London': self.TZ_LON}
1500
1501 return tz.tzstr(tzname_map[tzname])
1502
1503 def testStrTransition(self):
1504 # Check the abbreviation on either side of the DST transition.
1505 self.assertEqual(
1506 datetime(2003, 4, 6, 1, 59, tzinfo=tz.tzstr("EST5EDT")).tzname(),
1507 "EST",
1508 )
1509 self.assertEqual(
1510 datetime(2003, 4, 6, 2, 00, tzinfo=tz.tzstr("EST5EDT")).tzname(),
1511 "EDT",
1512 )
1513
1514 def testStrInequality(self):
1515 TZS1 = tz.tzstr('EST5EDT4')
1516
1517 # Standard abbreviation different
1518 TZS2 = tz.tzstr('ET5EDT4')
1519 self.assertNotEqual(TZS1, TZS2)
1520
1521 # DST abbreviation different
1522 TZS3 = tz.tzstr('EST5EMT')
1523 self.assertNotEqual(TZS1, TZS3)
1524
1525 # STD offset different
1526 TZS4 = tz.tzstr('EST4EDT4')
1527 self.assertNotEqual(TZS1, TZS4)
1528
1529 # DST offset different
1530 TZS5 = tz.tzstr('EST5EDT3')
1531 self.assertNotEqual(TZS1, TZS5)
1532
1533 def testStrInequalityStartEnd(self):
1534 TZS1 = tz.tzstr('EST5EDT4')
1535
1536 # Start delta different
1537 TZS2 = tz.tzstr('EST5EDT4,M4.2.0/02:00:00,M10-5-0/02:00')
1538 self.assertNotEqual(TZS1, TZS2)
1539
1540 # End delta different

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected