Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e54371e

Browse files
committed
Use unittest.skipUnless to skip the test related to the glibc bug, issue #13309.
1 parent 4ff29db commit e54371e

1 file changed

Lines changed: 13 additions & 12 deletions

File tree

Lib/test/test_time.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import locale
55
import sysconfig
66
import sys
7-
import warnings
87
import 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

327328
class TestLocale(unittest.TestCase):

0 commit comments

Comments
 (0)