@@ -220,6 +220,25 @@ Command-line options
220
220
221
221
See `Signal Handling `_ for the functions that provide this functionality.
222
222
223
+ .. cmdoption :: --debug
224
+
225
+ On test fail or error the test run terminates immediately with original
226
+ exception - similar to normal script execution. Useful for seamless external
227
+ post-mortem handling.
228
+
229
+ .. cmdoption :: --pdb
230
+
231
+ Runs ``pdb.post_mortem() `` upon each error. Short for ``--pm=pdb ``
232
+
233
+ .. cmdoption :: --pm
234
+
235
+ Run custom post-mortem debugger (module or class) upon each error.
236
+ Examples: ``--pm=pywin.debugger ``, ``--pm=IPython.terminal.debugger.Pdb ``
237
+
238
+ .. cmdoption :: --trace
239
+
240
+ Break at the beginning of each test using :mod: `pdb ` or the debugger set by ``--pm ``
241
+
223
242
.. cmdoption :: -f, --failfast
224
243
225
244
Stop the test run on the first error or failure.
@@ -253,6 +272,9 @@ Command-line options
253
272
.. versionadded :: 3.7
254
273
The command-line option ``-k ``.
255
274
275
+ .. versionadded :: 3.12
276
+ The command-line options ``--debug ``, ``--pdb `` and ``--pm ``.
277
+
256
278
The command line can also be used for test discovery, for running all of the
257
279
tests in a project or just a subset.
258
280
@@ -2228,7 +2250,8 @@ Loading and running tests
2228
2250
2229
2251
.. function :: main(module='__main__', defaultTest=None, argv=None, testRunner=None, \
2230
2252
testLoader=unittest.defaultTestLoader, exit=True, verbosity=1, \
2231
- failfast=None, catchbreak=None, buffer=None, warnings=None)
2253
+ failfast=None, catchbreak=None, buffer=None, warnings=None, \
2254
+ debug=False)
2232
2255
2233
2256
A command-line program that loads a set of tests from *module * and runs them;
2234
2257
this is primarily for making test modules conveniently executable.
@@ -2279,6 +2302,12 @@ Loading and running tests
2279
2302
Calling ``main `` actually returns an instance of the ``TestProgram `` class.
2280
2303
This stores the result of the tests run as the ``result `` attribute.
2281
2304
2305
+ When *debug * is ``True `` (corresponding to ``--debug ``) execution terminates
2306
+ with original exception upon the first error. When *debug * is the name of a
2307
+ debugger module or class - for example ":mod: `pdb `" - then post-mortem debugging is
2308
+ run upon each error.
2309
+
2310
+
2282
2311
.. versionchanged :: 3.1
2283
2312
The *exit * parameter was added.
2284
2313
@@ -2290,6 +2319,9 @@ Loading and running tests
2290
2319
The *defaultTest * parameter was changed to also accept an iterable of
2291
2320
test names.
2292
2321
2322
+ .. versionchanged :: 3.12
2323
+ The *debug * parameter was added.
2324
+
2293
2325
2294
2326
load_tests Protocol
2295
2327
###################
0 commit comments