mirror of
https://github.com/python/cpython.git
synced 2025-08-02 16:13:13 +00:00
parent
e96b229d2a
commit
711bf30b89
4 changed files with 47 additions and 0 deletions
|
@ -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:
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue