Issue #25168: Temporary timezone and cache debugging

This commit is contained in:
Martin Panter 2015-11-14 08:54:30 +00:00
parent 449e7c1b06
commit 63c1ebb67b

View file

@ -1979,7 +1979,16 @@ class TestDateTime(TestDate):
seconds = tzseconds
hours, minutes = divmod(seconds//60, 60)
dtstr = "{}{:02d}{:02d} {}".format(sign, hours, minutes, tzname)
try:
dt = strptime(dtstr, "%z %Z")
except ValueError:
import os
self.fail(
"Issue #25168 strptime() failure info:\n"
f"_TimeRE_cache['Z']={_strptime._TimeRE_cache['Z']!r}\n"
f"TZ={os.environ.get('TZ')!r}, or {os.getenv('TZ')!r} via getenv()\n"
f"_regex_cache={_strptime._regex_cache!r}\n"
)
self.assertEqual(dt.utcoffset(), timedelta(seconds=tzseconds))
self.assertEqual(dt.tzname(), tzname)
# Can produce inconsistent datetime