from django.test import TestCase


class ExceptionTest(TestCase):

    def test_call_raises_exception_with_custom_message(self):
        with self.assertRaisesMessage(Exception, 'My custom message!'):
            call_that_causes_exception()
Django/Python assertRaises with message check