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