          self.assertFalse(A.objects.filter(name='cascade_nullable').exists())
  
      def test_protect(self):
          a = create_a('protect')
          with self.assertRaises(IntegrityError):
              a.protect.delete()
  
      def test_do_nothing(self):
          # Testing DO_NOTHING is a bit harder: It would raise IntegrityError for a normal model,
          # so we connect to pre_delete and set the fk to a known value.
 
</s> remove         with self.assertRaises(ValueError):
 </s> add         msg = 'Cannot force an update in save() with no primary key.'
        with self.assertRaisesMessage(ValueError, msg): </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. Provide a success_url.'
        with self.assertRaisesMessage(ImproperlyConfigured, msg): </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(ValueError):
 </s> add         msg = 'The database backend does not accept 0 as a value for AutoField.'
        with self.assertRaisesMessage(ValueError, 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):
        msg = (
            "Cannot delete some instances of model 'R' because they are "
            "referenced through a protected foreign key: 'A.protect'"
        )
        with self.assertRaisesMessage(IntegrityError, msg):
          self.assertFalse(A.objects.filter(name='cascade_nullable').exists())
  
      def test_protect(self):
          a = create_a('protect')
        msg = (
            "Cannot delete some instances of model 'R' because they are "
            "referenced through a protected foreign key: 'A.protect'"
        )
        with self.assertRaisesMessage(IntegrityError, msg):
              a.protect.delete()
  
      def test_do_nothing(self):
          # Testing DO_NOTHING is a bit harder: It would raise IntegrityError for a normal model,
          # so we connect to pre_delete and set the fk to a known value.
keep keep keep keep replace keep keep keep keep keep
 Used assertRaisesMessage() to test Django's error messages. 
tests/delete/tests.py