mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
Closes issue #23600: Wrong results from tzinfo.fromutc().
This commit is contained in:
commit
c58c2cb392
3 changed files with 27 additions and 1 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue