Skip to content

Commit

Permalink
Extra tests for cases when the time module has different data.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamadden committed Aug 3, 2017
1 parent 3a94c0d commit 1031c82
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/zope/datetime/__init__.py
Expand Up @@ -338,7 +338,7 @@ def _findLocalTimeZoneName(isDST):
m = '+' if majorOffset >= 0 else ''
lz = '%s%0.02d%0.02d' % (m, majorOffset, minorOffset)
_localzone = _cache._zmap[('GMT%s' % lz).lower()]
except Exception: # pragma: no cover
except Exception:
_localzone = ''
return _localzone

Expand Down
13 changes: 13 additions & 0 deletions src/zope/datetime/tests/test_datetime.py
Expand Up @@ -49,6 +49,10 @@ def i(*args):
def test_safegmtime(self):
self.assertIsNotNone(datetime.safegmtime(6000))


def test_safelocaltime(self):
self.assertIsNotNone(datetime.safelocaltime(6000))

def test_calcSD(self):
s, d = datetime._calcSD(9)
self.assertAlmostEqual(s, 0, places=1)
Expand All @@ -70,6 +74,15 @@ def test_calendarday(self):
answer = (-4712, 1, 3) if str is bytes else (-4711, 2, 0)
self.assertEqual(datetime._calendarday(1), answer)

def test_findLocalTimeZoneName(self):
zmap = datetime._cache._zmap
try:
datetime._cache._zmap = {}
name = datetime._findLocalTimeZoneName(True)
self.assertEqual('', name)
finally:
datetime._cache._zmap = zmap


class TestTimezone(unittest.TestCase):

Expand Down

0 comments on commit 1031c82

Please sign in to comment.