mirror of
https://github.com/python/cpython.git
synced 2025-10-17 12:18:23 +00:00
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.
This commit is contained in:
parent
3ff55a8155
commit
1b8f26c2ed
1 changed files with 13 additions and 13 deletions
|
@ -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):
|
||||||
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):
|
||||||
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):
|
||||||
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,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue