max
max

Reputation: 52343

Asking unittest to raise an exception on first failure

I am trying to debug a failing test. Is there a way to ask unittest to not catch an exception from a test, but rather let it go through to the debugger?

It seems unittest just added --failfast option, but it still catches the exception inside unittest, and only stops it from running any further tests.

Upvotes: 0

Views: 284

Answers (1)

User
User

Reputation: 14883

I looked up the source and there is only one exception that comes through.

module: unittest.case

            ...
            try:
                testMethod()
            except KeyboardInterrupt:
                raise
            except ...

You can raise this or you will need to overwrite the run() method of your testcase and/or use an other result class.

Upvotes: 1

Related Questions