return eats exception
I found the following behavior at least weird:
I found the following behavior at least weird:
If I run the following code from a terminal, I get a helpful error message in the terminal:
I have a function that looks like this:
Let’s say I want to be able to log to file every time any exception is raised, anywhere in my program. I don’t want to modify any existing code.
The docs say that calling sys.exit() raises a SystemExit exception which can be caught in outer levels. I have a situation in which I want to definitively and unquestionably exit from inside a test case, however the unittest module catches SystemExit and prevents the exit. This is normally great, but the specific situation I am trying to handle is one where our test framework has detected that it is configured to point to a non-test database. In this case I want to exit and prevent any further tests from being run. Of course since unittest traps the SystemExit and continues happily on it’s way, it is thwarting me.