From 3ed1be9fbd2146dc841f9c88652f9db902ac797e Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Mon, 3 May 1999 19:57:01 +0000 Subject: [PATCH] Regression test for date format code, by Mike Meyer. (I tweaked it slightly so examples are allowed to have no date too.) --- Lib/test/test_rfc822.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/Lib/test/test_rfc822.py b/Lib/test/test_rfc822.py index a2b51513e44..798ae2b43c7 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 To: "Guido van @@ -40,6 +56,7 @@ test2 test('''From: Barry +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" +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 , "'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'),