Python - test that succeeds when exception is not raised
问题 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? 回答1: 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. 回答2: def runTest(self):