[New-bugs-announce] [issue42722] Add --debug command line option to unittest to enable post-mortem debugging
report at bugs.python.org
Tue Dec 22 18:46:51 EST 2020
New submission from Dominik V. <dominik.vilsmeier1123 at gmail.com>:
Currently there is no option to use post-mortem debugging via `pdb`
on a `unittest` test case which fails due to an exception being leaked.
Consider the following example:
for x in [1, 2, 'oops', 4]:
print(x + 100)
if __name__ == '__main__':
If we were calling `foo` directly we could enter post-mortem debugging via
`python -m pdb test.py`.
However since `foo` is wrapped in a test case, `unittest` eats the
exception and thus prevents post-mortem debugging.
So I propose adding a
command-line option `--debug` to unittest for running
test cases in debug mode so that post-mortem debugging can be used.
I see that some third-party distributions enable this, but since both
`unittest` and `pdb` are part of the standard library, it would
be nice if they played well together.
Plus the required methods are already in place (`TestCase.debug`
There is also a popular StackOverflow question on this topic:
nosy: Dominik V.
title: Add --debug command line option to unittest to enable post-mortem debugging
Python tracker <report at bugs.python.org>
More information about the New-bugs-announce