My test is not catching psycopg2.IntegrityError with assertRaises. I am using Flask-SQLAlchemy.
def test_insert_cash_flow(self):
cf = CashFlow()
db.session.add(cf)
self.assertRaises(psycopg2.IntegrityError, db.session.commit)
My CashFlow SQLAlchemy model has several nullable=False fields. It says my tests failed and IntegrityError is printed to the screen but my assertRaises does not catch this. Does anyone have any suspicion why?