              raise_exception = True
  
          request = self.factory.get('/rand')
          request.user = AnonymousUser()
          self.assertRaises(PermissionDenied, AView.as_view(), request)
  
      def test_raise_exception_custom_message(self):
          msg = "You don't have access here"
  
          class AView(AlwaysFalseView):
 
</s> remove         self.assertRaises(PermissionDenied, AView.as_view(), request)
 </s> add         with self.assertRaises(PermissionDenied):
            AView.as_view()(request) </s> remove         self.assertRaises(PermissionDenied, a_view, request)
 </s> add         with self.assertRaises(PermissionDenied):
            a_view(request) </s> remove         self.assertRaises(ImproperlyConfigured, get_user, request)
 </s> add         with self.assertRaises(ImproperlyConfigured):
            get_user(request) </s> remove         self.assertRaises(TypeError, build_abc)
 </s> add         with self.assertRaises(TypeError):
            build_abc() </s> remove         self.assertRaises(TypeError, build_no_base_classes)
 </s> add         with self.assertRaises(TypeError):
            build_no_base_classes()
        with self.assertRaises(PermissionDenied):
            AView.as_view()(request)
              raise_exception = True
  
          request = self.factory.get('/rand')
          request.user = AnonymousUser()
        with self.assertRaises(PermissionDenied):
            AView.as_view()(request)
  
      def test_raise_exception_custom_message(self):
          msg = "You don't have access here"
  
          class AView(AlwaysFalseView):
keep keep keep keep replace keep keep keep keep keep
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/auth_tests/test_mixins.py