diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2002-09-22 09:01:08 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2002-09-22 09:01:08 (GMT) |
commit | a6026c6a0ff6835fb2bdd0c904cb4be8b4b5c19f (patch) | |
tree | 565a8e8db5c165414c57ae4fcd4f876926549d7f /Lib/test | |
parent | 4a385834562645bbd34c3cc3d91769b89f86f1c6 (diff) | |
download | cpython-a6026c6a0ff6835fb2bdd0c904cb4be8b4b5c19f.zip cpython-a6026c6a0ff6835fb2bdd0c904cb4be8b4b5c19f.tar.gz cpython-a6026c6a0ff6835fb2bdd0c904cb4be8b4b5c19f.tar.bz2 |
Back out multifile.py 1.19 and 1.20. Fixes #514676.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_multifile.py | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/Lib/test/test_multifile.py b/Lib/test/test_multifile.py new file mode 100644 index 0000000..8f70347 --- /dev/null +++ b/Lib/test/test_multifile.py @@ -0,0 +1,66 @@ +import mimetools +import multifile +import cStringIO + +msg = """Mime-Version: 1.0 +Content-Type: multipart/mixed; + boundary="=====================_590453667==_" +X-OriginalArrivalTime: 05 Feb 2002 03:43:23.0310 (UTC) FILETIME=[42D88CE0:01C1ADF7] + +--=====================_590453667==_ +Content-Type: multipart/alternative; + boundary="=====================_590453677==_.ALT" + +--=====================_590453677==_.ALT +Content-Type: text/plain; charset="us-ascii"; format=flowed + +test A +--=====================_590453677==_.ALT +Content-Type: text/html; charset="us-ascii" + +<html> +<b>test B</font></b></html> + +--=====================_590453677==_.ALT-- + +--=====================_590453667==_ +Content-Type: text/plain; charset="us-ascii" +Content-Disposition: attachment; filename="att.txt" + +Attached Content. +Attached Content. +Attached Content. +Attached Content. + +--=====================_590453667==_-- + +""" + +boundaries = 0 +linecount = 0 + +def getMIMEMsg(mf): + global boundaries, linecount + msg = mimetools.Message(mf) + + #print "TYPE: %s" % msg.gettype() + if msg.getmaintype() == 'multipart': + boundary = msg.getparam("boundary") + boundaries += 1 + + mf.push(boundary) + while mf.next(): + getMIMEMsg(mf) + mf.pop() + else: + lines = mf.readlines() + linecount += len(lines) + +def main(): + f = cStringIO.StringIO(msg) + getMIMEMsg(multifile.MultiFile(f)) + assert boundaries == 2 + assert linecount == 9 + +if __name__ == '__main__': + main() |