(original) (raw)

changeset: 102613:05120447f2c6 user: Alexander Belopolsky alexander.belopolsky@gmail.com date: Thu Aug 11 11:01:45 2016 -0400 files: Lib/test/datetimetester.py description: Issue #24773: Fix and speed-up ZoneInfoCompleteTest. * Read the zone.tab file for the list of zones to exclude the aliases. * Skip Casablanca and El_Aaiun October 2037 transitions. diff -r 2eb84fe85889 -r 05120447f2c6 Lib/test/datetimetester.py --- a/Lib/test/datetimetester.py Wed Aug 10 23:44:54 2016 -0400 +++ b/Lib/test/datetimetester.py Thu Aug 11 11:01:45 2016 -0400 @@ -15,7 +15,6 @@ import random import struct import unittest -import sysconfig from array import array @@ -4591,13 +4590,16 @@ def zonenames(cls, zonedir=None): if zonedir is None: zonedir = cls.zoneroot - for root, _, files in os.walk(zonedir): - for f in files: - p = os.path.join(root, f) - with open(p, 'rb') as o: - magic = o.read(4) - if magic == b'TZif': - yield p[len(zonedir) + 1:] + zone_tab = os.path.join(zonedir, 'zone.tab') + try: + f = open(zone_tab) + except OSError: + return + with f: + for line in f: + line = line.strip() + if line and not line.startswith('#'): + yield line.split()[2] @classmethod def stats(cls, start_year=1): @@ -4692,7 +4694,6 @@ zonename = 'America/New_York' def setUp(self): - self.sizeof_time_t = sysconfig.get_config_var('SIZEOF_TIME_T') if sys.platform == "win32": self.skipTest("Skipping zoneinfo tests on Windows") try: @@ -4765,12 +4766,11 @@ try: _time.tzset() for udt, shift in tz.transitions(): - if self.zonename == 'Europe/Tallinn' and udt.date() == date(1999, 10, 31): + if (self.zonename == 'Europe/Tallinn' and udt.date() == date(1999, 10, 31) or + self.zonename.endswith(('Casablanca', 'El_Aaiun')) and + udt.date() == date(2037, 10, 4)): print("Skip %s %s transition" % (self.zonename, udt)) continue - if self.sizeof_time_t == 4 and udt.year >= 2037: - print("Skip %s %s transition for 32-bit time_t" % (self.zonename, udt)) - continue s0 = (udt - datetime(1970, 1, 1)) // SEC ss = shift // SEC # shift seconds for x in [-40 * 3600, -20*3600, -1, 0, /alexander.belopolsky@gmail.com