summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_doctest.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2006-04-25 03:31:36 (GMT)
committerTim Peters <tim.peters@gmail.com>2006-04-25 03:31:36 (GMT)
commit711bf30b898c73a94f56b7edfb7dd10d5999cb27 (patch)
tree8414796c446936b19ae6949dc5a7cae548847a5e /Lib/test/test_doctest.py
parente96b229d2ad3944592b1889bb277388fec086049 (diff)
downloadcpython-711bf30b898c73a94f56b7edfb7dd10d5999cb27.zip
cpython-711bf30b898c73a94f56b7edfb7dd10d5999cb27.tar.gz
cpython-711bf30b898c73a94f56b7edfb7dd10d5999cb27.tar.bz2
Patch #1475231: add a new SKIP doctest option, thanks to
Edward Loper.
Diffstat (limited to 'Lib/test/test_doctest.py')
-rw-r--r--Lib/test/test_doctest.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index b17607d..d39aa42 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -1079,6 +1079,25 @@ output to match any substring in the actual output:
... # doctest: +NORMALIZE_WHITESPACE
[0, 1, ..., 18, 19]
+The SKIP flag causes an example to be skipped entirely. I.e., the
+example is not run. It can be useful in contexts where doctest
+examples serve as both documentation and test cases, and an example
+should be included for documentation purposes, but should not be
+checked (e.g., because its output is random, or depends on resources
+which would be unavailable.) The SKIP flag can also be used for
+'commenting out' broken examples.
+
+ >>> import unavailable_resource # doctest: +SKIP
+ >>> unavailable_resource.do_something() # doctest: +SKIP
+ >>> unavailable_resource.blow_up() # doctest: +SKIP
+ Traceback (most recent call last):
+ ...
+ UncheckedBlowUpError: Nobody checks me.
+
+ >>> import random
+ >>> print random.random() # doctest: +SKIP
+ 0.721216923889
+
The REPORT_UDIFF flag causes failures that involve multi-line expected
and actual outputs to be displayed using a unified diff: