          a = Author.objects.create(
              name='Randall Munroe',
              slug='randall-munroe',
          )
          # Should raise exception -- No redirect URL provided, and no
          # get_absolute_url provided
          with self.assertRaises(ImproperlyConfigured):
              self.client.post('/edit/author/%d/delete/naive/' % a.pk)
 
</s> remove         # Should raise exception -- No redirect URL provided, and no
        # get_absolute_url provided
        with self.assertRaises(ImproperlyConfigured):
 </s> add         msg = (
            'No URL to redirect to.  Either provide a url or define a '
            'get_absolute_url method on the Model.'
        )
        with self.assertRaisesMessage(ImproperlyConfigured, msg): </s> remove         with self.assertRaises(ImproperlyConfigured):
 </s> add         msg = (
            'No URL to redirect to.  Either provide a url or define a '
            'get_absolute_url method on the Model.'
        )
        with self.assertRaisesMessage(ImproperlyConfigured, msg): </s> remove         with self.assertRaises(TemplateSyntaxError):
 </s> add         msg = "Variables and attributes may not begin with underscores: 'article._hidden'"
        with self.assertRaisesMessage(TemplateSyntaxError, msg): </s> remove         with self.assertRaises(ValueError):
 </s> add         msg = "The annotation 'book_contact_set' conflicts with a field on the model."
        with self.assertRaisesMessage(ValueError, msg): </s> remove         with self.assertRaises(AssertionError):
 </s> add         msg = (
            "earliest() and latest() require either a field_name parameter or "
            "'get_latest_by' in the model"
        )
        with self.assertRaisesMessage(AssertionError, msg):
        msg = 'No URL to redirect to. Provide a success_url.'
        with self.assertRaisesMessage(ImproperlyConfigured, msg):
          a = Author.objects.create(
              name='Randall Munroe',
              slug='randall-munroe',
          )
        msg = 'No URL to redirect to. Provide a success_url.'
        with self.assertRaisesMessage(ImproperlyConfigured, msg):
        msg = 'No URL to redirect to. Provide a success_url.'
        with self.assertRaisesMessage(ImproperlyConfigured, msg):
        msg = 'No URL to redirect to. Provide a success_url.'
        with self.assertRaisesMessage(ImproperlyConfigured, msg):
              self.client.post('/edit/author/%d/delete/naive/' % a.pk)
keep keep keep keep replace replace replace keep
 Used assertRaisesMessage() to test Django's error messages. 
tests/generic_views/test_edit.py