summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2015-09-28 01:56:09 (GMT)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2015-09-28 01:56:09 (GMT)
commitc58c2cb392479fb88e999ff99404e32b94f93cf0 (patch)
tree5dbd18dd69d27c0c5ae6e8409a48dbc4ac3741b0 /Lib
parentc944e34959914faabb57d18be7c04176d2bc5024 (diff)
parentc79447b267b391857f4e61a8e05c97ff01f3e61a (diff)
downloadcpython-c58c2cb392479fb88e999ff99404e32b94f93cf0.zip
cpython-c58c2cb392479fb88e999ff99404e32b94f93cf0.tar.gz
cpython-c58c2cb392479fb88e999ff99404e32b94f93cf0.tar.bz2
Closes issue #23600: Wrong results from tzinfo.fromutc().
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/datetimetester.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/Lib/test/datetimetester.py b/Lib/test/datetimetester.py
index 357fe13..63c3ae8 100644
--- a/Lib/test/datetimetester.py
+++ b/Lib/test/datetimetester.py
@@ -192,6 +192,29 @@ class TestTZInfo(unittest.TestCase):
self.assertEqual(derived.utcoffset(None), offset)
self.assertEqual(derived.tzname(None), oname)
+ def test_issue23600(self):
+ DSTDIFF = DSTOFFSET = timedelta(hours=1)
+
+ class UKSummerTime(tzinfo):
+ """Simple time zone which pretends to always be in summer time, since
+ that's what shows the failure.
+ """
+
+ def utcoffset(self, dt):
+ return DSTOFFSET
+
+ def dst(self, dt):
+ return DSTDIFF
+
+ def tzname(self, dt):
+ return 'UKSummerTime'
+
+ tz = UKSummerTime()
+ u = datetime(2014, 4, 26, 12, 1, tzinfo=tz)
+ t = tz.fromutc(u)
+ self.assertEqual(t - t.utcoffset(), u)
+
+
class TestTimeZone(unittest.TestCase):
def setUp(self):