summaryrefslogtreecommitdiffstats
path: root/Lib/test/datetimetester.py
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2015-09-28 02:31:45 (GMT)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2015-09-28 02:31:45 (GMT)
commitedc6885b3f6967df017be18a9b935f5599f10e19 (patch)
tree9b0383fafe72ae0ea91bded40465ab0112d0f414 /Lib/test/datetimetester.py
parent113843937615b26fe8c0a4402c754c176cb7293a (diff)
downloadcpython-edc6885b3f6967df017be18a9b935f5599f10e19.zip
cpython-edc6885b3f6967df017be18a9b935f5599f10e19.tar.gz
cpython-edc6885b3f6967df017be18a9b935f5599f10e19.tar.bz2
Closes issue #23600: Wrong results from tzinfo.fromutc().
Diffstat (limited to 'Lib/test/datetimetester.py')
-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 a942d4d..3d50fc1 100644
--- a/Lib/test/datetimetester.py
+++ b/Lib/test/datetimetester.py
@@ -180,6 +180,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):