I have read this Q&A, and already try to catch exception on my code that raise an IntegrityError exception, this way :
self.assertRaises(IntegrityError, db.session.commit())
But somehow my unit test still failed and stop with IntegrityError exception. I expect it to say OK as I already expect to have exception in my unit test. This was cause by code that tries to insert row having the same unique field values.
Any idea?