diff options
author | Guido van Rossum <guido@python.org> | 1999-05-03 19:57:01 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1999-05-03 19:57:01 (GMT) |
commit | 3ed1be9fbd2146dc841f9c88652f9db902ac797e (patch) | |
tree | 196a21472cf568aaf9a75b771d80780f39355879 /Lib/test/test_rfc822.py | |
parent | 4f13669cf0d348d521dda039cc7ff9fbef8dea40 (diff) | |
download | cpython-3ed1be9fbd2146dc841f9c88652f9db902ac797e.zip cpython-3ed1be9fbd2146dc841f9c88652f9db902ac797e.tar.gz cpython-3ed1be9fbd2146dc841f9c88652f9db902ac797e.tar.bz2 |
Regression test for date format code, by Mike Meyer.
(I tweaked it slightly so examples are allowed to have no date too.)
Diffstat (limited to 'Lib/test/test_rfc822.py')
-rw-r--r-- | Lib/test/test_rfc822.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/Lib/test/test_rfc822.py b/Lib/test/test_rfc822.py index a2b5151..798ae2b 100644 --- a/Lib/test/test_rfc822.py +++ b/Lib/test/test_rfc822.py @@ -11,6 +11,7 @@ def test(msg, results): fp.seek(0) m = rfc822.Message(fp) i = 0 + for n, a in m.getaddrlist('to') + m.getaddrlist('cc'): if verbose: print 'name:', repr(n), 'addr:', repr(a) @@ -28,6 +29,21 @@ def test(msg, results): print ' [no match]' print 'not found:', repr(n), repr(a) + out = m.getdate('date') + if out: + if verbose: + print 'Date:', m.getheader('date') + if out == (1999, 1, 13, 23, 57, 35, 0, 0, 0): + if verbose: + print ' [matched]' + else: + if verbose: + print ' [no match]' + print 'Date conversion failed:', out + +# Note: all test cases must have the same date (in various formats), +# or no date! + test('''Date: Wed, 13 Jan 1999 23:57:35 -0500 From: Guido van Rossum <guido@CNRI.Reston.VA.US> To: "Guido van @@ -40,6 +56,7 @@ test2 test('''From: Barry <bwarsaw@python.org To: guido@python.org (Guido: the Barbarian) Subject: nonsense +Date: Wednesday, January 13 1999 23:57:35 -0500 test''', [('Guido: the Barbarian', 'guido@python.org'), ]) @@ -47,6 +64,7 @@ test''', [('Guido: the Barbarian', 'guido@python.org'), test('''From: Barry <bwarsaw@python.org To: guido@python.org (Guido: the Barbarian) Cc: "Guido: the Madman" <guido@python.org> +Date: 13-Jan-1999 23:57:35 EST test''', [('Guido: the Barbarian', 'guido@python.org'), ('Guido: the Madman', 'guido@python.org') @@ -54,6 +72,7 @@ test''', [('Guido: the Barbarian', 'guido@python.org'), test('''To: "The monster with the very long name: Guido" <guido@python.org> +Date: Wed, 13 Jan 1999 23:57:35 -0500 test''', [('The monster with\n the very long name: Guido', 'guido@python.org')]) @@ -63,6 +82,7 @@ CC: Mike Fletcher <mfletch@vrtelecom.com>, "'string-sig@python.org'" <string-sig@python.org> Cc: fooz@bat.com, bart@toof.com Cc: goit@lip.com +Date: Wed, 13 Jan 1999 23:57:35 -0500 test''', [('Amit J. Patel', 'amitp@Theory.Stanford.EDU'), ('Mike Fletcher', 'mfletch@vrtelecom.com'), @@ -75,6 +95,7 @@ test''', [('Amit J. Patel', 'amitp@Theory.Stanford.EDU'), # This one is just twisted. I don't know what the proper result should be, # but it shouldn't be to infloop, which is what used to happen! test('''To: <[smtp:dd47@mail.xxx.edu]_at_hmhq@hdq-mdm1-imgout.companay.com> +Date: Wed, 13 Jan 1999 23:57:35 -0500 test''', [('', ''), ('', 'dd47@mail.xxx.edu'), |