diff -r 365b5e6163a6 Doc/library/email.iterators.rst --- a/Doc/library/email.iterators.rst Fri Jun 03 19:14:52 2016 +0000 +++ b/Doc/library/email.iterators.rst Fri Jun 03 17:00:47 2016 -0700 @@ -47,9 +47,9 @@ .. testsetup:: ->>> import email ->>> from email.iterators import _structure ->>> somefile = open('Lib/test/test_email/data/msg_02.txt') + import email + from email.iterators import _structure + somefile = open('../Lib/test/test_email/data/msg_02.txt') .. doctest:: @@ -71,9 +71,9 @@ text/plain text/plain - .. testsetup:: + .. testcleanup:: ->>> somefile.close() + somefile.close() Optional *fp* is a file-like object to print the output to. It must be suitable for Python's :func:`print` function. *level* is used internally. diff -r 365b5e6163a6 Doc/library/email.message.rst --- a/Doc/library/email.message.rst Fri Jun 03 19:14:52 2016 +0000 +++ b/Doc/library/email.message.rst Fri Jun 03 17:00:47 2016 -0700 @@ -599,10 +599,10 @@ .. testsetup:: ->>> from email import message_from_binary_file ->>> with open('Lib/test/test_email/data/msg_16.txt', 'rb') as f: - ... msg = message_from_binary_file(f) ->>> from email.iterators import _structure + from email import message_from_binary_file + with open('../Lib/test/test_email/data/msg_16.txt', 'rb') as f: + msg = message_from_binary_file(f) + from email.iterators import _structure .. doctest:: @@ -625,7 +625,7 @@ .. doctest:: >>> for part in msg.walk(): - ... print(part.get_content_maintype() == 'multipart'), + ... print(part.get_content_maintype() == 'multipart', ... part.is_multipart()) True True False False @@ -637,11 +637,11 @@ >>> _structure(msg) multipart/report text/plain - message/delivery-status - text/plain - text/plain - message/rfc822 - text/plain + message/delivery-status + text/plain + text/plain + message/rfc822 + text/plain Here the ``message`` parts are not ``multiparts``, but they do contain subparts. ``is_multipart()`` returns ``True`` and ``walk`` descends diff -r 365b5e6163a6 Doc/library/email.policy.rst --- a/Doc/library/email.policy.rst Fri Jun 03 19:14:52 2016 +0000 +++ b/Doc/library/email.policy.rst Fri Jun 03 17:00:47 2016 -0700 @@ -60,16 +60,15 @@ .. testsetup:: ->>> from unittest import mock ->>> mocker = mock.patch('subprocess.Popen') ->>> m = mocker.start() ->>> proc = mock.MagicMock() ->>> m.return_value = proc ->>> proc.stdin.close.return_value = None ->>> mymsg = open('mymsg.txt', 'w') ->>> mymsg.write('To: abc@xyz.com\n\n') - 17 ->>> mymsg.flush() + from unittest import mock + mocker = mock.patch('subprocess.Popen') + m = mocker.start() + proc = mock.MagicMock() + m.return_value = proc + proc.stdin.close.return_value = None + mymsg = open('mymsg.txt', 'w') + mymsg.write('To: abc@xyz.com\n\n') + mymsg.flush() .. doctest:: @@ -85,12 +84,12 @@ >>> p.stdin.close() >>> rc = p.wait() -.. testsetup:: +.. testcleanup:: ->>> mymsg.close() ->>> mocker.stop() ->>> import os ->>> os.remove('mymsg.txt') + mymsg.close() + mocker.stop() + import os + os.remove('mymsg.txt') Here we are telling :class:`~email.generator.BytesGenerator` to use the RFC correct line separator characters when creating the binary string to feed into

AltStyle によって変換されたページ (->オリジナル) /