How does one write a unit test that fails only if a function doesn't throw an expected exception?
Use TestCase.assertRaises from the unittest module, for example:
TestCase.assertRaises
unittest
import mymod class MyTestCase(unittest.TestCase): def test1(self): self.assertRaises(SomeCoolException, mymod.myfunc)