diff options
author | ishepard <spadini.davide@gmail.com> | 2018-04-04 10:04:23 +0200 |
---|---|---|
committer | Sebastian Thiel <byronimo@gmail.com> | 2018-04-04 10:15:48 +0200 |
commit | c6e0a6cb5c70efd0899f620f83eeebcc464be05c (patch) | |
tree | d8fc4f051490ac5a889c0ac51d2f2069b8ec924c /git/test/test_util.py | |
parent | 0857d33852b6b2f4d7bc470b4c97502c7f978180 (diff) | |
download | gitpython-c6e0a6cb5c70efd0899f620f83eeebcc464be05c.tar.gz |
Avoid from_timestamp() function to raise an exception when the offset is greater or lower than 24 hours.
Add tests that exercise the new behaviour
Diffstat (limited to 'git/test/test_util.py')
-rw-r--r-- | git/test/test_util.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/git/test/test_util.py b/git/test/test_util.py index b7925c84..9c993205 100644 --- a/git/test/test_util.py +++ b/git/test/test_util.py @@ -7,7 +7,7 @@ import tempfile import time from unittest import skipIf - +from datetime import datetime import ddt @@ -18,7 +18,8 @@ from git.objects.util import ( utctz_to_altz, verify_utctz, parse_date, -) + tzoffset, + from_timestamp) from git.test.lib import ( TestBase, assert_equal @@ -260,3 +261,16 @@ class TestUtils(TestBase): self.failUnlessRaises(IndexError, ilist.__delitem__, 0) self.failUnlessRaises(IndexError, ilist.__delitem__, 'something') + + def test_from_timestamp(self): + # Correct offset: UTC+2, should return datetime + tzoffset(+2) + altz = utctz_to_altz('+0200') + self.assertEqual(datetime.fromtimestamp(1522827734, tzoffset(altz)), from_timestamp(1522827734, altz)) + + # Wrong offset: UTC+58, should return datetime + tzoffset(UTC) + altz = utctz_to_altz('+5800') + self.assertEqual(datetime.fromtimestamp(1522827734, tzoffset(0)), from_timestamp(1522827734, altz)) + + # Wrong offset: UTC-9000, should return datetime + tzoffset(UTC) + altz = utctz_to_altz('-9000') + self.assertEqual(datetime.fromtimestamp(1522827734, tzoffset(0)), from_timestamp(1522827734, altz)) |