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)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)