summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_doctest.py
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2004-08-19 16:38:58 (GMT)
committerTim Peters <tim.peters@gmail.com>2004-08-19 16:38:58 (GMT)
commit026f8dc103da360b4edea5128f3939a6b660e2f2 (patch)
tree6f81dea14220160f7cd73c14beb9d5a0a495ca0c /Lib/test/test_doctest.py
parent3caf9c1edd0623231489d998a81511c9fa991f5a (diff)
downloadcpython-026f8dc103da360b4edea5128f3939a6b660e2f2.zip
cpython-026f8dc103da360b4edea5128f3939a6b660e2f2.tar.gz
cpython-026f8dc103da360b4edea5128f3939a6b660e2f2.tar.bz2
Now that they've settled down, document doctest directives.
Diffstat (limited to 'Lib/test/test_doctest.py')
-rw-r--r--Lib/test/test_doctest.py20
1 files changed, 17 insertions, 3 deletions
diff --git a/Lib/test/test_doctest.py b/Lib/test/test_doctest.py
index e96fd2a..245a9f4 100644
--- a/Lib/test/test_doctest.py
+++ b/Lib/test/test_doctest.py
@@ -758,6 +758,11 @@ treated as equal:
>>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test)
(0, 1)
+ An example from the docs:
+ >>> print range(20) #doctest: +NORMALIZE_WHITESPACE
+ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,
+ 10, 11, 12, 13, 14, 15, 16, 17, 18, 19]
+
The ELLIPSIS flag causes ellipsis marker ("...") in the expected
output to match any substring in the actual output:
@@ -780,8 +785,8 @@ output to match any substring in the actual output:
>>> doctest.DocTestRunner(verbose=False, optionflags=flags).run(test)
(0, 1)
-... should also match nothing gracefully (note that a regular-expression
-implementation of ELLIPSIS would take a loooong time to match this one!):
+ ... should also match nothing gracefully (note that a regular-expression
+ implementation of ELLIPSIS would take a loooong time to match this one!):
>>> for i in range(100):
... print i**2 #doctest: +ELLIPSIS
@@ -801,7 +806,7 @@ implementation of ELLIPSIS would take a loooong time to match this one!):
9801
...
-... can be surprising; e.g., this test passes:
+ ... can be surprising; e.g., this test passes:
>>> for i in range(21): #doctest: +ELLIPSIS
... print i
@@ -815,6 +820,15 @@ implementation of ELLIPSIS would take a loooong time to match this one!):
...
0
+ Examples from the docs:
+
+ >>> print range(20) # doctest:+ELLIPSIS
+ [0, 1, ..., 18, 19]
+
+ >>> print range(20) # doctest: +ELLIPSIS
+ ... # doctest: +NORMALIZE_WHITESPACE
+ [0, 1, ..., 18, 19]
+
The UNIFIED_DIFF flag causes failures that involve multi-line expected
and actual outputs to be displayed using a unified diff: