@@ -177,15 +177,8 @@ prohibit it by passing ``verbose=False``. In either of those cases,
177177``sys.argv `` is not examined by :func: `testmod ` (so passing ``-v `` or not
178178has no effect).
179179
180- There is also a command line shortcut for running :func: `testmod `. You can
181- instruct the Python interpreter to run the doctest module directly from the
182- standard library and pass the module name(s) on the command line::
183-
184- python -m doctest -v example.py
185-
186- This will import :file: `example.py ` as a standalone module and run
187- :func: `testmod ` on it. Note that this may not work correctly if the file is
188- part of a package and imports other submodules from that package.
180+ There is also a command line shortcut for running :func: `testmod `, see section
181+ :ref: `doctest-cli `.
189182
190183For more information on :func: `testmod `, see section :ref: `doctest-basic-api `.
191184
@@ -248,16 +241,53 @@ Like :func:`testmod`, :func:`testfile`'s verbosity can be set with the
248241``-v `` command-line switch or with the optional keyword argument
249242*verbose *.
250243
251- There is also a command line shortcut for running :func: `testfile `. You can
252- instruct the Python interpreter to run the doctest module directly from the
253- standard library and pass the file name(s) on the command line::
244+ There is also a command line shortcut for running :func: `testfile `, see section
245+ :ref: `doctest-cli `.
254246
255- python -m doctest -v example.txt
247+ For more information on :func: ` testfile `, see section :ref: ` doctest-basic-api `.
256248
257- Because the file name does not end with :file: `.py `, :mod: `doctest ` infers that
258- it must be run with :func: `testfile `, not :func: `testmod `.
259249
260- For more information on :func: `testfile `, see section :ref: `doctest-basic-api `.
250+ .. _doctest-cli :
251+
252+ Command-line Usage
253+ ------------------
254+
255+ The :mod: `doctest ` module can be invoked as a script from the command line:
256+
257+ .. code-block :: bash
258+
259+ python -m doctest [-v] [-o OPTION] [-f] file [file ...]
260+
261+ .. program :: doctest
262+
263+ .. option :: -v , --verbose
264+
265+ Detailed report of all examples tried is printed to standard output,
266+ along with assorted summaries at the end::
267+
268+ python -m doctest -v example.py
269+
270+ This will import :file: `example.py ` as a standalone module and run
271+ :func: `testmod ` on it. Note that this may not work correctly if the
272+ file is part of a package and imports other submodules from that package.
273+
274+ If the file name does not end with :file: `.py `, :mod: `!doctest ` infers
275+ that it must be run with :func: `testfile ` instead::
276+
277+ python -m doctest -v example.txt
278+
279+ .. option :: -o , --option <option >
280+
281+ Option flags control various aspects of doctest's behavior, see section
282+ :ref: `doctest-options `.
283+
284+ .. versionadded :: 3.4
285+
286+ .. option :: -f , --fail-fast
287+
288+ This is shorthand for ``-o FAIL_FAST ``.
289+
290+ .. versionadded :: 3.4
261291
262292
263293.. _doctest-how-it-works :
@@ -540,9 +570,6 @@ Symbolic names for the flags are supplied as module constants, which can be
540570The names can also be used in :ref: `doctest directives <doctest-directives >`,
541571and may be passed to the doctest command line interface via the ``-o `` option.
542572
543- .. versionadded :: 3.4
544- The ``-o `` command line option.
545-
546573The first group of options define test semantics, controlling aspects of how
547574doctest decides whether actual output matches an example's expected output:
548575
@@ -682,11 +709,6 @@ The second group of options controls how test failures are reported:
682709 1. This flag may be useful during debugging, since examples after the first
683710 failure won't even produce debugging output.
684711
685- The doctest command line accepts the option ``-f `` as a shorthand for ``-o
686- FAIL_FAST ``.
687-
688- .. versionadded :: 3.4
689-
690712
691713.. data :: REPORTING_FLAGS
692714
0 commit comments