summaryrefslogtreecommitdiffstats
path: root/Lib/dos-8x3/test_rfc.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-05-08 17:31:04 (GMT)
committerGuido van Rossum <guido@python.org>2000-05-08 17:31:04 (GMT)
commitaad6761ccea28e0a0da6761570b18adc72e01c37 (patch)
tree731b55d5648f08e1bc755bcace1f836413cd8aae /Lib/dos-8x3/test_rfc.py
parent0b095bc0929fb43157019c50e3e680a29ec94a65 (diff)
downloadcpython-aad6761ccea28e0a0da6761570b18adc72e01c37.zip
cpython-aad6761ccea28e0a0da6761570b18adc72e01c37.tar.gz
cpython-aad6761ccea28e0a0da6761570b18adc72e01c37.tar.bz2
The usual...
Diffstat (limited to 'Lib/dos-8x3/test_rfc.py')
-rw-r--r--Lib/dos-8x3/test_rfc.py40
1 files changed, 40 insertions, 0 deletions
diff --git a/Lib/dos-8x3/test_rfc.py b/Lib/dos-8x3/test_rfc.py
index b8ae8c7..0d4c66f 100644
--- a/Lib/dos-8x3/test_rfc.py
+++ b/Lib/dos-8x3/test_rfc.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,8 +95,28 @@ 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'),
('', '_at_hmhq@hdq-mdm1-imgout.companay.com')
])
+
+# This exercises the old commas-in-a-full-name bug, which should be doing the
+# right thing in recent versions of the module.
+test('''To: "last, first" <userid@foo.net>
+
+test''', [('last, first', 'userid@foo.net'),
+ ])
+
+test('''To: (Comment stuff) "Quoted name"@somewhere.com
+
+test''', [('Comment stuff', '"Quoted name"@somewhere.com'),
+ ])
+
+test('''To: :
+Cc: goit@lip.com
+Date: Wed, 13 Jan 1999 23:57:35 -0500
+
+test''', [('', 'goit@lip.com')])
+