Issue
How does one write a unittest that fails only if a function doesn't throw an expected exception?
Solution
Use TestCase.assertRaises (or TestCase.failUnlessRaises) from the unittest module, for example:
import mymod
class MyTestCase(unittest.TestCase):
def test1(self):
self.assertRaises(SomeCoolException, mymod.myfunc)
Answered By - Moe Answer Checked By - Candace Johnson (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.