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

Class TZStrTest

tests/test_tz.py:1407–1521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1405
1406@pytest.mark.tzstr
1407class TZStrTest(unittest.TestCase, TzFoldMixin):
1408 # POSIX string indicating change to summer time on the 2nd Sunday in March
1409 # at 2AM, and ending the 1st Sunday in November at 2AM. (valid >= 2007)
1410 TZ_EST = 'EST+5EDT,M3.2.0/2,M11.1.0/2'
1411
1412 # POSIX string for AEST/AEDT (valid >= 2008)
1413 TZ_AEST = 'AEST-10AEDT,M10.1.0/2,M4.1.0/3'
1414
1415 # POSIX string for GMT/BST
1416 TZ_LON = 'GMT0BST,M3.5.0,M10.5.0'
1417
1418 def gettz(self, tzname):
1419 # Actual time zone changes are handled by the _gettz_context function
1420 tzname_map = {'Australia/Sydney': self.TZ_AEST,
1421 'America/Toronto': self.TZ_EST,
1422 'America/New_York': self.TZ_EST,
1423 'Europe/London': self.TZ_LON}
1424
1425 return tz.tzstr(tzname_map[tzname])
1426
1427 def testStrStr(self):
1428 # Test that tz.tzstr() won't throw an error if given a str instead
1429 # of a unicode literal.
1430 self.assertEqual(datetime(2003, 4, 6, 1, 59,
1431 tzinfo=tz.tzstr(str("EST5EDT"))).tzname(), "EST")
1432 self.assertEqual(datetime(2003, 4, 6, 2, 00,
1433 tzinfo=tz.tzstr(str("EST5EDT"))).tzname(), "EDT")
1434
1435 def testStrInequality(self):
1436 TZS1 = tz.tzstr('EST5EDT4')
1437
1438 # Standard abbreviation different
1439 TZS2 = tz.tzstr('ET5EDT4')
1440 self.assertNotEqual(TZS1, TZS2)
1441
1442 # DST abbreviation different
1443 TZS3 = tz.tzstr('EST5EMT')
1444 self.assertNotEqual(TZS1, TZS3)
1445
1446 # STD offset different
1447 TZS4 = tz.tzstr('EST4EDT4')
1448 self.assertNotEqual(TZS1, TZS4)
1449
1450 # DST offset different
1451 TZS5 = tz.tzstr('EST5EDT3')
1452 self.assertNotEqual(TZS1, TZS5)
1453
1454 def testStrInequalityStartEnd(self):
1455 TZS1 = tz.tzstr('EST5EDT4')
1456
1457 # Start delta different
1458 TZS2 = tz.tzstr('EST5EDT4,M4.2.0/02:00:00,M10-5-0/02:00')
1459 self.assertNotEqual(TZS1, TZS2)
1460
1461 # End delta different
1462 TZS3 = tz.tzstr('EST5EDT4,M4.2.0/02:00:00,M11-5-0/02:00')
1463 self.assertNotEqual(TZS1, TZS3)
1464

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected