Python - test that succeeds when exception is not raised

exception, python, unit-testing

Solution

The test runner will catch all exceptions you didn't assert would be raised. Thus:

doStuff()
self.assert_(True)

This should work fine. You can leave out the self.assert_ call, since it doesn't really do anything. I like to put it there to document that I didn't forget an assertion.

Problem

I know about `unittest` Python module. I know about `assertRaises()` method of `TestCase` class. I would like to write a test that succeeds when an exception is not raised. Any hints please?

Original source

Related problems