#18584: make doctest examples in email documentation pass.
With the exception of the 'as_string' call in the policy docs.
That one is a separate issue.
Note that when building the docs sphinx is complaining about
.. testcleanup:: being an invalid directive. I don't know
why this is, as I'm following the sphinx docs...but fortunately
the action is to omit the text in the body, so the generated
documentation is correct.
diff --git a/Doc/library/email.iterators.rst b/Doc/library/email.iterators.rst
index d1f1797..6c7200f 100644
--- a/Doc/library/email.iterators.rst
+++ b/Doc/library/email.iterators.rst
@@ -33,14 +33,22 @@
Thus, by default :func:`typed_subpart_iterator` returns each subpart that has a
MIME type of :mimetype:`text/\*`.
+
The following function has been added as a useful debugging tool. It should
*not* be considered part of the supported public interface for the package.
-
.. function:: _structure(msg, fp=None, level=0, include_default=False)
Prints an indented representation of the content types of the message object
- structure. For example::
+ structure. For example:
+
+ .. testsetup::
+
+ >>> import email
+ >>> from email.iterators import _structure
+ >>> somefile = open('Lib/test/test_email/data/msg_02.txt')
+
+ .. doctest::
>>> msg = email.message_from_file(somefile)
>>> _structure(msg)
@@ -60,6 +68,10 @@
text/plain
text/plain
+ .. testcleanup::
+
+ >>> 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.
*include_default*, if true, prints the default type as well.