Commit 1b8f26c2 authored by Alexander Belopolsky's avatar Alexander Belopolsky

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.
parent 3ff55a81
...@@ -15,7 +15,6 @@ import pickle ...@@ -15,7 +15,6 @@ import pickle
import random import random
import struct import struct
import unittest import unittest
import sysconfig
from array import array from array import array
...@@ -4591,13 +4590,16 @@ class ZoneInfo(tzinfo): ...@@ -4591,13 +4590,16 @@ class ZoneInfo(tzinfo):
def zonenames(cls, zonedir=None): def zonenames(cls, zonedir=None):
if zonedir is None: if zonedir is None:
zonedir = cls.zoneroot zonedir = cls.zoneroot
for root, _, files in os.walk(zonedir): zone_tab = os.path.join(zonedir, 'zone.tab')
for f in files: try:
p = os.path.join(root, f) f = open(zone_tab)
with open(p, 'rb') as o: except OSError:
magic = o.read(4) return
if magic == b'TZif': with f:
yield p[len(zonedir) + 1:] for line in f:
line = line.strip()
if line and not line.startswith('#'):
yield line.split()[2]
@classmethod @classmethod
def stats(cls, start_year=1): def stats(cls, start_year=1):
...@@ -4692,7 +4694,6 @@ class ZoneInfoTest(unittest.TestCase): ...@@ -4692,7 +4694,6 @@ class ZoneInfoTest(unittest.TestCase):
zonename = 'America/New_York' zonename = 'America/New_York'
def setUp(self): def setUp(self):
self.sizeof_time_t = sysconfig.get_config_var('SIZEOF_TIME_T')
if sys.platform == "win32": if sys.platform == "win32":
self.skipTest("Skipping zoneinfo tests on Windows") self.skipTest("Skipping zoneinfo tests on Windows")
try: try:
...@@ -4765,12 +4766,11 @@ class ZoneInfoTest(unittest.TestCase): ...@@ -4765,12 +4766,11 @@ class ZoneInfoTest(unittest.TestCase):
try: try:
_time.tzset() _time.tzset()
for udt, shift in tz.transitions(): 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)) print("Skip %s %s transition" % (self.zonename, udt))
continue 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 s0 = (udt - datetime(1970, 1, 1)) // SEC
ss = shift // SEC # shift seconds ss = shift // SEC # shift seconds
for x in [-40 * 3600, -20*3600, -1, 0, for x in [-40 * 3600, -20*3600, -1, 0,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment