Consider the following example:

    import unittest

    def foo():
        for x in [1, 2, 'oops', 4]:
            print(x + 100)

    class TestFoo(unittest.TestCase):
        def test_foo(self):
            self.assertIs(foo(), None)

    if __name__ == '__main__':
        unittest.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. `--failfast` doesn't help, the 
exception is still swallowed.

Since I am not aware of a solution that enables post-mortem debugging in such a 
case (without modifying the test scripts, please correct me if one exists), I 
propose adding a command-line option to `unittest` for [running test cases in 
debug 
mode](https://docs.python.org/3/library/unittest.html#unittest.TestCase.debug) 
so that post-mortem debugging can be used.

P.S.: There is also [this SO 
question](https://stackoverflow.com/q/4398967/3767239) on a similar topic.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/NO66SFJ37RB7W65BK46CRCZDIRJ7VCHQ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to