@@ -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,52 @@ 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 file is
272+ part of a package and imports other submodules from that package.
273+ If the file name does not end with :file: `.py `, :mod: `doctest ` infers that
274+ it must be run with :func: `testfile `, not :func: `testmod `::
275+
276+ python -m doctest -v example.txt
277+
278+ .. option :: -o , --option <option >
279+
280+ Option flags control various aspects of doctest's behavior, see section
281+ :ref: `doctest-options `.
282+
283+ .. versionadded :: 3.4
284+
285+ .. option :: -f , --fail-fast
286+
287+ This is shorthand for ``-o FAIL_FAST ``.
288+
289+ .. versionadded :: 3.4
261290
262291
263292.. _doctest-how-it-works :
@@ -540,9 +569,6 @@ Symbolic names for the flags are supplied as module constants, which can be
540569The names can also be used in :ref: `doctest directives <doctest-directives >`,
541570and may be passed to the doctest command line interface via the ``-o `` option.
542571
543- .. versionadded :: 3.4
544- The ``-o `` command line option.
545-
546572The first group of options define test semantics, controlling aspects of how
547573doctest decides whether actual output matches an example's expected output:
548574
@@ -682,11 +708,6 @@ The second group of options controls how test failures are reported:
682708 1. This flag may be useful during debugging, since examples after the first
683709 failure won't even produce debugging output.
684710
685- The doctest command line accepts the option ``-f `` as a shorthand for ``-o
686- FAIL_FAST ``.
687-
688- .. versionadded :: 3.4
689-
690711
691712.. data :: REPORTING_FLAGS
692713
0 commit comments