44import locale
55import sysconfig
66import sys
7- import warnings
87import platform
98
109# Max year is only limited by the size of C int.
@@ -200,8 +199,8 @@ def test_ctime(self):
200199 else :
201200 self .assertEqual (time .ctime (testval )[20 :], str (year ))
202201
203- @unittest .skipIf ( not hasattr (time , "tzset" ),
204- "time module has no attribute tzset" )
202+ @unittest .skipUnless ( hasattr (time , "tzset" ),
203+ "time module has no attribute tzset" )
205204 def test_tzset (self ):
206205
207206 from os import environ
@@ -298,8 +297,7 @@ def test_localtime_without_arg(self):
298297 t1 = time .mktime (lt1 )
299298 self .assertAlmostEqual (t1 , t0 , delta = 0.2 )
300299
301- # XXX run last to work around issue #13309 on Gentoo
302- def test_zzz_mktime (self ):
300+ def test_mktime (self ):
303301 # Issue #1726687
304302 for t in (- 2 , - 1 , 0 , 1 ):
305303 try :
@@ -308,20 +306,23 @@ def test_zzz_mktime(self):
308306 pass
309307 else :
310308 self .assertEqual (time .mktime (tt ), t )
311- tt = time .gmtime (self .t )
312- tzname = time .strftime ('%Z' , tt )
313- self .assertNotEqual (tzname , 'LMT' )
309+
310+ # Issue #13309: passing extreme values to mktime() or localtime()
311+ # borks the glibc's internal timezone data.
312+ @unittest .skipUnless (platform .libc_ver ()[0 ] != 'glibc' ,
313+ "disabled because of a bug in glibc. Issue #13309" )
314+ def test_mktime_error (self ):
314315 # It may not be possible to reliably make mktime return error
315316 # on all platfom. This will make sure that no other exception
316317 # than OverflowError is raised for an extreme value.
317- if platform .libc_ver ()[0 ] == 'glibc' :
318- # Issue #13309: passing extreme values to mktime() or localtime()
319- # borks the glibc's internal timezone data.
320- return
318+ tt = time .gmtime (self .t )
319+ tzname = time .strftime ('%Z' , tt )
320+ self .assertNotEqual (tzname , 'LMT' )
321321 try :
322322 time .mktime ((- 1 , 1 , 1 , 0 , 0 , 0 , - 1 , - 1 , - 1 ))
323323 except OverflowError :
324324 pass
325+ self .assertEqual (time .strftime ('%Z' , tt ), tzname )
325326
326327
327328class TestLocale (unittest .TestCase ):
0 commit comments