summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2016-08-11 15:01:45 (GMT)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2016-08-11 15:01:45 (GMT)
commit1b8f26c2ed6a360356285b1ff95d6cdd18e3276c (patch)
treeadc1f55c7c26b6454483e9b07e23cbb6baa261cc /Lib
parent3ff55a815559c91cfd8a7573e63ea6c3b7124484 (diff)
downloadcpython-1b8f26c2ed6a360356285b1ff95d6cdd18e3276c.zip
cpython-1b8f26c2ed6a360356285b1ff95d6cdd18e3276c.tar.gz
cpython-1b8f26c2ed6a360356285b1ff95d6cdd18e3276c.tar.bz2
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.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/datetimetester.py26
1 files changed, 13 insertions, 13 deletions
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
index 726b7fd..65eae72 100644
--- a/Lib/test/datetimetester.py
+++ b/Lib/test/datetimetester.py
@@ -15,7 +15,6 @@ import pickle
import random
import struct
import unittest
-import sysconfig
from array import array
@@ -4591,13 +4590,16 @@ class ZoneInfo(tzinfo):
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 @@ class ZoneInfoTest(unittest.TestCase):
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 @@ class ZoneInfoTest(unittest.TestCase):
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,