]> git.proxmox.com Git - mirror_edk2.git/blame - AppPkg/Applications/Python/Python-2.7.2/Lib/test/test_multifile.py
EmbeddedPkg: Extend NvVarStoreFormattedLib LIBRARY_CLASS
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Lib / test / test_multifile.py
CommitLineData
4710c53d 1from test import test_support\r
2mimetools = test_support.import_module('mimetools', deprecated=True)\r
3multifile = test_support.import_module('multifile', deprecated=True)\r
4import cStringIO\r
5\r
6msg = """Mime-Version: 1.0\r
7Content-Type: multipart/mixed;\r
8 boundary="=====================_590453667==_"\r
9X-OriginalArrivalTime: 05 Feb 2002 03:43:23.0310 (UTC) FILETIME=[42D88CE0:01C1ADF7]\r
10\r
11--=====================_590453667==_\r
12Content-Type: multipart/alternative;\r
13 boundary="=====================_590453677==_.ALT"\r
14\r
15--=====================_590453677==_.ALT\r
16Content-Type: text/plain; charset="us-ascii"; format=flowed\r
17\r
18test A\r
19--=====================_590453677==_.ALT\r
20Content-Type: text/html; charset="us-ascii"\r
21\r
22<html>\r
23<b>test B</font></b></html>\r
24\r
25--=====================_590453677==_.ALT--\r
26\r
27--=====================_590453667==_\r
28Content-Type: text/plain; charset="us-ascii"\r
29Content-Disposition: attachment; filename="att.txt"\r
30\r
31Attached Content.\r
32Attached Content.\r
33Attached Content.\r
34Attached Content.\r
35\r
36--=====================_590453667==_--\r
37\r
38"""\r
39\r
40def getMIMEMsg(mf):\r
41 global boundaries, linecount\r
42 msg = mimetools.Message(mf)\r
43\r
44 #print "TYPE: %s" % msg.gettype()\r
45 if msg.getmaintype() == 'multipart':\r
46 boundary = msg.getparam("boundary")\r
47 boundaries += 1\r
48\r
49 mf.push(boundary)\r
50 while mf.next():\r
51 getMIMEMsg(mf)\r
52 mf.pop()\r
53 else:\r
54 lines = mf.readlines()\r
55 linecount += len(lines)\r
56\r
57def test_main():\r
58 global boundaries, linecount\r
59 boundaries = 0\r
60 linecount = 0\r
61 f = cStringIO.StringIO(msg)\r
62 getMIMEMsg(multifile.MultiFile(f))\r
63 assert boundaries == 2\r
64 assert linecount == 9\r
65\r
66if __name__ == '__main__':\r
67 test_main()\r