          self.assertFalse(A.objects.filter(name='cascade_nullable').exists())
  
      def test_protect(self):
          a = create_a('protect')
          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.
          replacement_r = R.objects.create()
 
</s> remove         self.assertRaises(KeyError, self.client.get, "/broken_view/")
 </s> add         with self.assertRaises(KeyError):
            self.client.get("/broken_view/") </s> remove         self.assertRaises(AttributeError, set_session_key, self.session)
 </s> add         with self.assertRaises(AttributeError):
            set_session_key(self.session) </s> remove         self.assertRaises(MissingForeignKey, lm.save, silent=True, strict=True)
 </s> add         with self.assertRaises(MissingForeignKey):
            lm.save(silent=True, strict=True) </s> remove         self.assertRaises(ValidationError, f.clean, False)
 </s> add         with self.assertRaises(ValidationError):
            f.clean(False) </s> remove         self.assertRaises(Http404, get_object_or_404, Article, title="Foo")
 </s> add         with self.assertRaises(Http404):
            get_object_or_404(Article, title="Foo")
        with self.assertRaises(IntegrityError):
            a.protect.delete()
          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.
          replacement_r = R.objects.create()
keep keep keep keep replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/delete/tests.py