summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorRobert Collins <rbtcollins@hp.com>2015-07-31 20:18:22 (GMT)
committerRobert Collins <rbtcollins@hp.com>2015-07-31 20:18:22 (GMT)
commit2080dc97a7d629384a1dfbad9003f3cbd9011911 (patch)
tree110a87181d0f1ed77e70fd6d26d24dfe2d334405 /Lib/test
parent6fb1e740c67d8940fe27883d77f0dc46431aa9b4 (diff)
downloadcpython-2080dc97a7d629384a1dfbad9003f3cbd9011911.zip
cpython-2080dc97a7d629384a1dfbad9003f3cbd9011911.tar.gz
cpython-2080dc97a7d629384a1dfbad9003f3cbd9011911.tar.bz2
Issue #22932: Fix timezones in email.utils.formatdate.
Patch from Dmitry Shachnev.
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_email/test_utils.py20
1 files changed, 20 insertions, 0 deletions
diff --git a/Lib/test/test_email/test_utils.py b/Lib/test/test_email/test_utils.py
index 4abdc04..1e9cd63 100644
--- a/Lib/test/test_email/test_utils.py
+++ b/Lib/test/test_email/test_utils.py
@@ -136,5 +136,25 @@ class LocaltimeTests(unittest.TestCase):
t1 = utils.localtime(t0)
self.assertEqual(t1.tzname(), 'EET')
+class FormatDateTests(unittest.TestCase):
+
+ @test.support.run_with_tz('Europe/Minsk')
+ def test_formatdate(self):
+ timeval = time.mktime((2011, 12, 1, 18, 0, 0, 4, 335, 0))
+ string = utils.formatdate(timeval, localtime=False, usegmt=False)
+ self.assertEqual(string, 'Thu, 01 Dec 2011 15:00:00 -0000')
+ string = utils.formatdate(timeval, localtime=False, usegmt=True)
+ self.assertEqual(string, 'Thu, 01 Dec 2011 15:00:00 GMT')
+
+ @test.support.run_with_tz('Europe/Minsk')
+ def test_formatdate_with_localtime(self):
+ timeval = time.mktime((2011, 1, 1, 18, 0, 0, 6, 1, 0))
+ string = utils.formatdate(timeval, localtime=True)
+ self.assertEqual(string, 'Sat, 01 Jan 2011 18:00:00 +0200')
+ # Minsk moved from +0200 (with DST) to +0300 (without DST) in 2011
+ timeval = time.mktime((2011, 12, 1, 18, 0, 0, 4, 335, 0))
+ string = utils.formatdate(timeval, localtime=True)
+ self.assertEqual(string, 'Thu, 01 Dec 2011 18:00:00 +0300')
+
if __name__ == '__main__':
unittest.main()