          self.assertEqual(self.client.session['tobacconist'], 'hovercraft')
  
      def test_view_with_exception(self):
          "Request a page that is known to throw an error"
          self.assertRaises(KeyError, self.client.get, "/broken_view/")
  
          # Try the same assertion, a different way
          try:
              self.client.get('/broken_view/')
              self.fail('Should raise an error')
 
</s> remove         self.assertRaises(IntegrityError, a.protect.delete)
 </s> add         with self.assertRaises(IntegrityError):
            a.protect.delete() </s> remove         self.assertRaises(ImproperlyConfigured, self.backend)
 </s> add         with self.assertRaises(ImproperlyConfigured):
            self.backend() </s> remove         self.assertRaises(InvalidSessionKey,
                          self.backend()._key_to_file, "a\\b\\c")
 </s> add         with self.assertRaises(InvalidSessionKey):
            self.backend()._key_to_file("a\\b\\c") </s> remove             self.assertRaises(ValueError, self.client.get, '/bad_view/')
 </s> add             with self.assertRaises(ValueError):
                self.client.get('/bad_view/') </s> remove             self.assertRaises(School.DoesNotExist, lambda: private_director.school)
 </s> add             with self.assertRaises(School.DoesNotExist):
                private_director.school
        with self.assertRaises(KeyError):
            self.client.get("/broken_view/")
          self.assertEqual(self.client.session['tobacconist'], 'hovercraft')
  
      def test_view_with_exception(self):
          "Request a page that is known to throw an error"
        with self.assertRaises(KeyError):
            self.client.get("/broken_view/")
  
          # Try the same assertion, a different way
          try:
              self.client.get('/broken_view/')
              self.fail('Should raise an error')
keep keep keep keep replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/test_client/tests.py