diff options
author | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2012-06-23 01:03:39 (GMT) |
---|---|---|
committer | Alexander Belopolsky <alexander.belopolsky@gmail.com> | 2012-06-23 01:03:39 (GMT) |
commit | 8141cc7f8895778a430c4c8a65c65310e3c6afe7 (patch) | |
tree | 97468b29a67c9e3048815eb89ece3bfde2fe199b /Lib/test/test_imaplib.py | |
parent | 60c13ddd9b03cb28f454e37ddb1214d4ae4f5e82 (diff) | |
download | cpython-8141cc7f8895778a430c4c8a65c65310e3c6afe7.zip cpython-8141cc7f8895778a430c4c8a65c65310e3c6afe7.tar.gz cpython-8141cc7f8895778a430c4c8a65c65310e3c6afe7.tar.bz2 |
Issues #11024: Fixes and additional tests for Time2Internaldate.
Diffstat (limited to 'Lib/test/test_imaplib.py')
-rw-r--r-- | Lib/test/test_imaplib.py | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/Lib/test/test_imaplib.py b/Lib/test/test_imaplib.py index e629cb1..bfb9006 100644 --- a/Lib/test/test_imaplib.py +++ b/Lib/test/test_imaplib.py @@ -11,9 +11,9 @@ import socketserver import time import calendar -from test.support import reap_threads, verbose, transient_internet, run_with_tz +from test.support import reap_threads, verbose, transient_internet, run_with_tz, run_with_locale import unittest - +from datetime import datetime, timezone, timedelta try: import ssl except ImportError: @@ -43,14 +43,30 @@ class TestImaplib(unittest.TestCase): imaplib.Internaldate2tuple( b'25 (INTERNALDATE "02-Apr-2000 03:30:00 +0000")')) - def test_that_Time2Internaldate_returns_a_result(self): - # We can check only that it successfully produces a result, - # not the correctness of the result itself, since the result - # depends on the timezone the machine is in. - timevalues = [2000000000, 2000000000.0, time.localtime(2000000000), - '"18-May-2033 05:33:20 +0200"'] - for t in timevalues: + + def timevalues(self): + return [2000000000, 2000000000.0, time.localtime(2000000000), + (2033, 5, 18, 5, 33, 20, -1, -1, -1), + (2033, 5, 18, 5, 33, 20, -1, -1, 1), + datetime.fromtimestamp(2000000000, + timezone(timedelta(0, 2*60*60))), + '"18-May-2033 05:33:20 +0200"'] + + @run_with_locale('LC_ALL', 'de_DE', 'fr_FR') + @run_with_tz('STD-1DST') + def test_Time2Internaldate(self): + expected = '"18-May-2033 05:33:20 +0200"' + + for t in self.timevalues(): + internal = imaplib.Time2Internaldate(t) + self.assertEqual(internal, expected) + + def test_that_Time2Internaldate_returns_a_result(self): + # Without tzset, we can check only that it successfully + # produces a result, not the correctness of the result itself, + # since the result depends on the timezone the machine is in. + for t in self.timevalues(): imaplib.Time2Internaldate(t) |