File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,9 +50,9 @@ The following function has been added as a useful debugging tool. It should
5050
5151 .. testsetup ::
5252
53- >>> import email
54- >>> from email.iterators import _structure
55- >>> somefile = open (' Lib/test/test_email/data/msg_02.txt' )
53+ import email
54+ from email.iterators import _structure
55+ somefile = open('../ Lib/test/test_email/data/msg_02.txt')
5656
5757 .. doctest ::
5858
@@ -74,9 +74,9 @@ The following function has been added as a useful debugging tool. It should
7474 text/plain
7575 text/plain
7676
77- .. testsetup ::
77+ .. testcleanup ::
7878
79- >>> somefile.close()
79+ somefile.close()
8080
8181 Optional *fp * is a file-like object to print the output to. It must be
8282 suitable for Python's :func: `print ` function. *level * is used internally.
Original file line number Diff line number Diff line change @@ -602,10 +602,10 @@ Here are the methods of the :class:`Message` class:
602602
603603 .. testsetup ::
604604
605- >>> from email import message_from_binary_file
606- >>> with open (' Lib/test/test_email/data/msg_16.txt' , ' rb' ) as f:
607- ... msg = message_from_binary_file(f)
608- >>> from email.iterators import _structure
605+ from email import message_from_binary_file
606+ with open('../ Lib/test/test_email/data/msg_16.txt', 'rb') as f:
607+ msg = message_from_binary_file(f)
608+ from email.iterators import _structure
609609
610610 .. doctest ::
611611
@@ -628,7 +628,7 @@ Here are the methods of the :class:`Message` class:
628628 .. doctest ::
629629
630630 >>> for part in msg.walk():
631- ... print (part.get_content_maintype() == ' multipart' ) ,
631+ ... print (part.get_content_maintype() == ' multipart' ,
632632 ... part.is_multipart())
633633 True True
634634 False False
@@ -640,11 +640,11 @@ Here are the methods of the :class:`Message` class:
640640 >>> _structure(msg)
641641 multipart/report
642642 text/plain
643- message/delivery-status
644- text/plain
645- text/plain
646- message/rfc822
647- text/plain
643+ message/delivery-status
644+ text/plain
645+ text/plain
646+ message/rfc822
647+ text/plain
648648
649649 Here the ``message `` parts are not ``multiparts ``, but they do contain
650650 subparts. ``is_multipart() `` returns ``True `` and ``walk `` descends
Original file line number Diff line number Diff line change @@ -63,16 +63,15 @@ file on disk and pass it to the system ``sendmail`` program on a Unix system:
6363
6464.. testsetup ::
6565
66- >>> from unittest import mock
67- >>> mocker = mock.patch(' subprocess.Popen' )
68- >>> m = mocker.start()
69- >>> proc = mock.MagicMock()
70- >>> m.return_value = proc
71- >>> proc.stdin.close.return_value = None
72- >>> mymsg = open (' mymsg.txt' , ' w' )
73- >>> mymsg.write(' To: abc@xyz.com\n\n ' )
74- 17
75- >>> mymsg.flush()
66+ from unittest import mock
67+ mocker = mock.patch('subprocess.Popen')
68+ m = mocker.start()
69+ proc = mock.MagicMock()
70+ m.return_value = proc
71+ proc.stdin.close.return_value = None
72+ mymsg = open('mymsg.txt', 'w')
73+ mymsg.write('To: abc@xyz.com\n\n ')
74+ mymsg.flush()
7675
7776.. doctest ::
7877
@@ -88,12 +87,12 @@ file on disk and pass it to the system ``sendmail`` program on a Unix system:
8887 >>> p.stdin.close()
8988 >>> rc = p.wait()
9089
91- .. testsetup ::
90+ .. testcleanup ::
9291
93- >>> mymsg.close()
94- >>> mocker.stop()
95- >>> import os
96- >>> os.remove(' mymsg.txt' )
92+ mymsg.close()
93+ mocker.stop()
94+ import os
95+ os.remove('mymsg.txt')
9796
9897Here we are telling :class: `~email.generator.BytesGenerator ` to use the RFC
9998correct line separator characters when creating the binary string to feed into
You can’t perform that action at this time.
0 commit comments