|
39 | 39 | from email import utils
|
40 | 40 |
|
41 | 41 | from test.support import threading_helper
|
| 42 | +from test.support.warnings_helper import check_warnings |
42 | 43 | from test.support.os_helper import unlink
|
43 | 44 | from test.test_email import openfile, TestEmailBase
|
44 | 45 |
|
|
50 | 51 | EMPTYSTRING = ''
|
51 | 52 | SPACE = ' '
|
52 | 53 |
|
| 54 | +UU_WARNING_FILTER = ('.*uu.*', DeprecationWarning) |
| 55 | + |
53 | 56 |
|
54 | 57 | # Test various aspects of the Message class's API
|
55 | 58 | class TestMessageAPI(TestEmailBase):
|
@@ -263,10 +266,12 @@ def test_get_decoded_uu_payload(self):
|
263 | 266 | msg.set_payload('begin 666 -\n+:&5L;&\\@=V]R;&0 \n \nend\n')
|
264 | 267 | for cte in ('x-uuencode', 'uuencode', 'uue', 'x-uue'):
|
265 | 268 | msg['content-transfer-encoding'] = cte
|
266 |
| - eq(msg.get_payload(decode=True), b'hello world') |
| 269 | + with check_warnings(UU_WARNING_FILTER): |
| 270 | + eq(msg.get_payload(decode=True), b'hello world') |
267 | 271 | # Now try some bogus data
|
268 | 272 | msg.set_payload('foo')
|
269 |
| - eq(msg.get_payload(decode=True), b'foo') |
| 273 | + with check_warnings(UU_WARNING_FILTER): |
| 274 | + eq(msg.get_payload(decode=True), b'foo') |
270 | 275 |
|
271 | 276 | def test_get_payload_n_raises_on_non_multipart(self):
|
272 | 277 | msg = Message()
|
@@ -740,12 +745,13 @@ def test_binary_uuencode_payload(self):
|
740 | 745 | msg['content-type'] = 'text/plain; charset=%s' % charset
|
741 | 746 | msg['content-transfer-encoding'] = encoding
|
742 | 747 | msg.set_payload(b"begin 666 -\n)9F]OYI:'8F%R\n \nend\n")
|
743 |
| - self.assertEqual( |
744 |
| - msg.get_payload(decode=True), |
745 |
| - b'foo\xe6\x96\x87bar', |
746 |
| - str(('get_payload returns wrong result ', |
747 |
| - 'with charset {0} and encoding {1}.')).\ |
748 |
| - format(charset, encoding)) |
| 748 | + with check_warnings(UU_WARNING_FILTER): |
| 749 | + self.assertEqual( |
| 750 | + msg.get_payload(decode=True), |
| 751 | + b'foo\xe6\x96\x87bar', |
| 752 | + str(('get_payload returns wrong result ', |
| 753 | + 'with charset {0} and encoding {1}.')).\ |
| 754 | + format(charset, encoding)) |
749 | 755 |
|
750 | 756 | def test_add_header_with_name_only_param(self):
|
751 | 757 | msg = Message()
|
@@ -3963,8 +3969,9 @@ def test_8bit_in_uuencode_body(self):
|
3963 | 3969 | cte='uuencode',
|
3964 | 3970 | bodyline='<,.V<W1A; á ').encode('utf-8')
|
3965 | 3971 | msg = email.message_from_bytes(m)
|
3966 |
| - self.assertEqual(msg.get_payload(decode=True), |
3967 |
| - '<,.V<W1A; á \n'.encode('utf-8')) |
| 3972 | + with check_warnings(UU_WARNING_FILTER): |
| 3973 | + self.assertEqual(msg.get_payload(decode=True), |
| 3974 | + '<,.V<W1A; á \n'.encode('utf-8')) |
3968 | 3975 |
|
3969 | 3976 |
|
3970 | 3977 | headertest_headers = (
|
|
0 commit comments