Regression test for date format code, by Mike Meyer.

(I tweaked it slightly so examples are allowed to have no date too.)
This commit is contained in:
Guido van Rossum 1999-05-03 19:57:01 +00:00
parent 4f13669cf0
commit 3ed1be9fbd
1 changed files with 21 additions and 0 deletions

View File

@ -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'),