assertRaises in python unit-test not catching the exception [duplicate]
Unittest’s assertRaises takes a callable and arguments, so in your case, you’d call it like: self.assertRaises(ValueError, self.isone.is_one, 2) If you prefer, as of Python2.7, you could also use it as a context manager like: with self.assertRaises(ValueError): self.isone.is_one(2)