Mercurial > cpython-lru_cache-weakref
annotate Lib/test/test_MimeWriter.py @ 79675:c0a2294de787 2.7
Issue #16199: Backport 2to3 typo fix from 3.2.
| author | Chris Jerdonek <chris.jerdonek@gmail.com> |
|---|---|
| date | Thu, 11 Oct 2012 16:15:46 -0700 |
| parents | 07c7664f21a1 |
| children |
| rev | line source |
|---|---|
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
1 """Test program for MimeWriter module. |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
2 |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
3 The test program was too big to comfortably fit in the MimeWriter |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
4 class, so it's here in its own file. |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
5 |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
6 This should generate Barry's example, modulo some quotes and newlines. |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
7 |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
8 """ |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
9 |
|
45468
1d84bf5f9478
Patch #2167 from calvin: Remove unused imports
Christian Heimes <christian@cheimes.de>
parents:
41915
diff
changeset
|
10 import unittest, StringIO |
|
59726
07c7664f21a1
Various tests cleanup: check_warnings/check_py3k_warnings, unittest.assert* and setUp/tearDown.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
45468
diff
changeset
|
11 from test.test_support import run_unittest, import_module |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
12 |
|
59726
07c7664f21a1
Various tests cleanup: check_warnings/check_py3k_warnings, unittest.assert* and setUp/tearDown.
Florent Xicluna <florent.xicluna@gmail.com>
parents:
45468
diff
changeset
|
13 import_module("MimeWriter", deprecated=True) |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
14 from MimeWriter import MimeWriter |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
15 |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
16 SELLER = '''\ |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
17 INTERFACE Seller-1; |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
18 |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
19 TYPE Seller = OBJECT |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
20 DOCUMENTATION "A simple Seller interface to test ILU" |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
21 METHODS |
|
8475
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
22 price():INTEGER, |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
23 END; |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
24 ''' |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
25 |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
26 BUYER = '''\ |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
27 class Buyer: |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
28 def __setup__(self, maxprice): |
|
8475
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
29 self._maxprice = maxprice |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
30 |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
31 def __main__(self, kos): |
|
8475
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
32 """Entry point upon arrival at a new KOS.""" |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
33 broker = kos.broker() |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
34 # B4 == Barry's Big Bass Business :-) |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
35 seller = broker.lookup('Seller_1.Seller', 'B4') |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
36 if seller: |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
37 price = seller.price() |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
38 print 'Seller wants $', price, '... ' |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
39 if price > self._maxprice: |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
40 print 'too much!' |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
41 else: |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
42 print "I'll take it!" |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
43 else: |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
44 print 'no seller found here' |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
45 ''' # Don't ask why this comment is here |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
46 |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
47 STATE = '''\ |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
48 # instantiate a buyer instance and put it in a magic place for the KOS |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
49 # to find. |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
50 __kp__ = Buyer() |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
51 __kp__.__setup__(500) |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
52 ''' |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
53 |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
54 SIMPLE_METADATA = [ |
|
8475
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
55 ("Interpreter", "python"), |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
56 ("Interpreter-Version", "1.3"), |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
57 ("Owner-Name", "Barry Warsaw"), |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
58 ("Owner-Rendezvous", "bwarsaw@cnri.reston.va.us"), |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
59 ("Home-KSS", "kss.cnri.reston.va.us"), |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
60 ("Identifier", "hdl://cnri.kss/my_first_knowbot"), |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
61 ("Launch-Date", "Mon Feb 12 16:39:03 EST 1996"), |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
62 ] |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
63 |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
64 COMPLEX_METADATA = [ |
|
8475
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
65 ("Metadata-Type", "complex"), |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
66 ("Metadata-Key", "connection"), |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
67 ("Access", "read-only"), |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
68 ("Connection-Description", "Barry's Big Bass Business"), |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
69 ("Connection-Id", "B4"), |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
70 ("Connection-Direction", "client"), |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
71 ] |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
72 |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
73 EXTERNAL_METADATA = [ |
|
8475
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
74 ("Metadata-Type", "complex"), |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
75 ("Metadata-Key", "generic-interface"), |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
76 ("Access", "read-only"), |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
77 ("Connection-Description", "Generic Interface for All Knowbots"), |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
78 ("Connection-Id", "generic-kp"), |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
79 ("Connection-Direction", "client"), |
|
f8c6cf5cfa7d
Untabified -- to satisfy the tab nanny.
Guido van Rossum <guido@python.org>
parents:
8118
diff
changeset
|
80 ] |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
81 |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
82 |
|
40266
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
83 OUTPUT = '''\ |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
84 From: bwarsaw@cnri.reston.va.us |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
85 Date: Mon Feb 12 17:21:48 EST 1996 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
86 To: kss-submit@cnri.reston.va.us |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
87 MIME-Version: 1.0 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
88 Content-Type: multipart/knowbot; |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
89 boundary="801spam999"; |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
90 version="0.1" |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
91 |
|
40266
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
92 This is a multi-part message in MIME format. |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
93 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
94 --801spam999 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
95 Content-Type: multipart/knowbot-metadata; |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
96 boundary="802spam999" |
|
15305
07f24261c6e6
Make reindent.py happy (convert everything to 4-space indents!).
Fred Drake <fdrake@acm.org>
parents:
8475
diff
changeset
|
97 |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
98 |
|
40266
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
99 --802spam999 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
100 Content-Type: message/rfc822 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
101 KP-Metadata-Type: simple |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
102 KP-Access: read-only |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
103 |
|
40266
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
104 KPMD-Interpreter: python |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
105 KPMD-Interpreter-Version: 1.3 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
106 KPMD-Owner-Name: Barry Warsaw |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
107 KPMD-Owner-Rendezvous: bwarsaw@cnri.reston.va.us |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
108 KPMD-Home-KSS: kss.cnri.reston.va.us |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
109 KPMD-Identifier: hdl://cnri.kss/my_first_knowbot |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
110 KPMD-Launch-Date: Mon Feb 12 16:39:03 EST 1996 |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
111 |
|
40266
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
112 --802spam999 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
113 Content-Type: text/isl |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
114 KP-Metadata-Type: complex |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
115 KP-Metadata-Key: connection |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
116 KP-Access: read-only |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
117 KP-Connection-Description: Barry's Big Bass Business |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
118 KP-Connection-Id: B4 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
119 KP-Connection-Direction: client |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
120 |
|
40266
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
121 INTERFACE Seller-1; |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
122 |
|
40266
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
123 TYPE Seller = OBJECT |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
124 DOCUMENTATION "A simple Seller interface to test ILU" |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
125 METHODS |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
126 price():INTEGER, |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
127 END; |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
128 |
|
40266
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
129 --802spam999 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
130 Content-Type: message/external-body; |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
131 access-type="URL"; |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
132 URL="hdl://cnri.kss/generic-knowbot" |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
133 |
|
40266
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
134 Content-Type: text/isl |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
135 KP-Metadata-Type: complex |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
136 KP-Metadata-Key: generic-interface |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
137 KP-Access: read-only |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
138 KP-Connection-Description: Generic Interface for All Knowbots |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
139 KP-Connection-Id: generic-kp |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
140 KP-Connection-Direction: client |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
141 |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
142 |
|
40266
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
143 --802spam999-- |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
144 |
|
40266
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
145 --801spam999 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
146 Content-Type: multipart/knowbot-code; |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
147 boundary="803spam999" |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
148 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
149 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
150 --803spam999 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
151 Content-Type: text/plain |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
152 KP-Module-Name: BuyerKP |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
153 |
|
40266
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
154 class Buyer: |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
155 def __setup__(self, maxprice): |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
156 self._maxprice = maxprice |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
157 |
|
40266
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
158 def __main__(self, kos): |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
159 """Entry point upon arrival at a new KOS.""" |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
160 broker = kos.broker() |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
161 # B4 == Barry's Big Bass Business :-) |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
162 seller = broker.lookup('Seller_1.Seller', 'B4') |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
163 if seller: |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
164 price = seller.price() |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
165 print 'Seller wants $', price, '... ' |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
166 if price > self._maxprice: |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
167 print 'too much!' |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
168 else: |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
169 print "I'll take it!" |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
170 else: |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
171 print 'no seller found here' |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
172 |
|
40266
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
173 --803spam999-- |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
174 |
|
40266
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
175 --801spam999 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
176 Content-Type: multipart/knowbot-state; |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
177 boundary="804spam999" |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
178 KP-Main-Module: main |
|
8118
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
179 |
|
7cf51657b08c
Add test for MimeWriter module
Guido van Rossum <guido@python.org>
parents:
diff
changeset
|
180 |
|
40266
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
181 --804spam999 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
182 Content-Type: text/plain |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
183 KP-Module-Name: main |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
184 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
185 # instantiate a buyer instance and put it in a magic place for the KOS |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
186 # to find. |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
187 __kp__ = Buyer() |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
188 __kp__.__setup__(500) |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
189 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
190 --804spam999-- |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
191 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
192 --801spam999-- |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
193 ''' |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
194 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
195 class MimewriterTest(unittest.TestCase): |
|
40284
ff678669aa6e
Whitespace normalization.
Tim Peters <tim.peters@gmail.com>
parents:
40266
diff
changeset
|
196 |
|
40266
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
197 def test(self): |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
198 buf = StringIO.StringIO() |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
199 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
200 # Toplevel headers |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
201 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
202 toplevel = MimeWriter(buf) |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
203 toplevel.addheader("From", "bwarsaw@cnri.reston.va.us") |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
204 toplevel.addheader("Date", "Mon Feb 12 17:21:48 EST 1996") |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
205 toplevel.addheader("To", "kss-submit@cnri.reston.va.us") |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
206 toplevel.addheader("MIME-Version", "1.0") |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
207 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
208 # Toplevel body parts |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
209 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
210 f = toplevel.startmultipartbody("knowbot", "801spam999", |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
211 [("version", "0.1")], prefix=0) |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
212 f.write("This is a multi-part message in MIME format.\n") |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
213 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
214 # First toplevel body part: metadata |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
215 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
216 md = toplevel.nextpart() |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
217 md.startmultipartbody("knowbot-metadata", "802spam999") |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
218 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
219 # Metadata part 1 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
220 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
221 md1 = md.nextpart() |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
222 md1.addheader("KP-Metadata-Type", "simple") |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
223 md1.addheader("KP-Access", "read-only") |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
224 m = MimeWriter(md1.startbody("message/rfc822")) |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
225 for key, value in SIMPLE_METADATA: |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
226 m.addheader("KPMD-" + key, value) |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
227 m.flushheaders() |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
228 del md1 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
229 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
230 # Metadata part 2 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
231 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
232 md2 = md.nextpart() |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
233 for key, value in COMPLEX_METADATA: |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
234 md2.addheader("KP-" + key, value) |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
235 f = md2.startbody("text/isl") |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
236 f.write(SELLER) |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
237 del md2 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
238 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
239 # Metadata part 3 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
240 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
241 md3 = md.nextpart() |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
242 f = md3.startbody("message/external-body", |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
243 [("access-type", "URL"), |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
244 ("URL", "hdl://cnri.kss/generic-knowbot")]) |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
245 m = MimeWriter(f) |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
246 for key, value in EXTERNAL_METADATA: |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
247 md3.addheader("KP-" + key, value) |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
248 md3.startbody("text/isl") |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
249 # Phantom body doesn't need to be written |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
250 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
251 md.lastpart() |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
252 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
253 # Second toplevel body part: code |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
254 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
255 code = toplevel.nextpart() |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
256 code.startmultipartbody("knowbot-code", "803spam999") |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
257 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
258 # Code: buyer program source |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
259 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
260 buyer = code.nextpart() |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
261 buyer.addheader("KP-Module-Name", "BuyerKP") |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
262 f = buyer.startbody("text/plain") |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
263 f.write(BUYER) |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
264 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
265 code.lastpart() |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
266 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
267 # Third toplevel body part: state |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
268 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
269 state = toplevel.nextpart() |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
270 state.addheader("KP-Main-Module", "main") |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
271 state.startmultipartbody("knowbot-state", "804spam999") |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
272 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
273 # State: a bunch of assignments |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
274 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
275 st = state.nextpart() |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
276 st.addheader("KP-Module-Name", "main") |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
277 f = st.startbody("text/plain") |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
278 f.write(STATE) |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
279 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
280 state.lastpart() |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
281 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
282 # End toplevel body parts |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
283 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
284 toplevel.lastpart() |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
285 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
286 self.assertEqual(buf.getvalue(), OUTPUT) |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
287 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
288 def test_main(): |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
289 run_unittest(MimewriterTest) |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
290 |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
291 if __name__ == '__main__': |
|
1007328f9db5
Convert test_MimeWriter to unittest.
Georg Brandl <georg@python.org>
parents:
15305
diff
changeset
|
292 test_main() |
