summaryrefslogtreecommitdiff
path: root/doc/tutorial/describing-code.rst
diff options
context:
space:
mode:
authorJuan Luis Cano Rodríguez <hello@juanlu.space>2021-09-06 16:38:18 +0200
committerJuan Luis Cano Rodríguez <hello@juanlu.space>2021-09-06 16:38:18 +0200
commit70bc61f0f39acc41fad8494078be85dce3cc9bcc (patch)
treef5d8f61629fafe44caf76309a382f49232e34d4b /doc/tutorial/describing-code.rst
parent878478e725e1ee00b49079478780eb77107abc8f (diff)
downloadsphinx-git-70bc61f0f39acc41fad8494078be85dce3cc9bcc.tar.gz
Include explanation about doctests
Diffstat (limited to 'doc/tutorial/describing-code.rst')
-rw-r--r--doc/tutorial/describing-code.rst5
1 files changed, 5 insertions, 0 deletions
diff --git a/doc/tutorial/describing-code.rst b/doc/tutorial/describing-code.rst
index b1817b2b7..8988a8190 100644
--- a/doc/tutorial/describing-code.rst
+++ b/doc/tutorial/describing-code.rst
@@ -212,6 +212,11 @@ Then, write a doctest block as follows:
>>> lumache.get_random_ingredients()
['shells', 'gorgonzola', 'parsley']
+Doctests include the Python instructions to be run preceded by ``>>>``,
+the standard Python interpreter prompt, as well as the expected output
+of each instruction. This way, Sphinx can check whether the actual output
+matches the expected one.
+
To observe how a doctest failure looks like (rather than a code error as
above), let's write the return value incorrectly first. Therefore, add a
function ``get_random_ingredients`` like this: