summaryrefslogtreecommitdiffstats
path: root/Doc/library/email.iterators.rst
diff options
context:
space:
mode:
authorR David Murray <rdmurray@bitdance.com>2013-07-29 19:49:58 (GMT)
committerR David Murray <rdmurray@bitdance.com>2013-07-29 19:49:58 (GMT)
commitfdfb0050bb4e79724da052e06bab1c875076832a (patch)
tree31b34143e40072a797f656e440fdfaee72ae50b8 /Doc/library/email.iterators.rst
parentc06c0aed58db0f223e91607485de8a9fe77c3e7e (diff)
downloadcpython-fdfb0050bb4e79724da052e06bab1c875076832a.zip
cpython-fdfb0050bb4e79724da052e06bab1c875076832a.tar.gz
cpython-fdfb0050bb4e79724da052e06bab1c875076832a.tar.bz2
#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.
Diffstat (limited to 'Doc/library/email.iterators.rst')
-rw-r--r--Doc/library/email.iterators.rst16
1 files changed, 14 insertions, 2 deletions
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 @@ useful higher level iterations over message object trees.
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 @@ The following function has been added as a useful debugging tool. It should
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.