          def a_view(request):
              return HttpResponse()
          request = self.factory.get('/rand')
          request.user = self.user
          self.assertRaises(PermissionDenied, a_view, request)
 
</s> remove         self.assertRaises(PermissionDenied, AView.as_view(), request)
 </s> add         with self.assertRaises(PermissionDenied):
            AView.as_view()(request) </s> remove         self.assertRaises(PermissionDenied, AView.as_view(), request)
 </s> add         with self.assertRaises(PermissionDenied):
            AView.as_view()(request) </s> remove         self.assertRaises(signing.BadSignature,
            request.get_signed_cookie, 'c')
 </s> add         with self.assertRaises(signing.BadSignature):
            request.get_signed_cookie('c') </s> remove         self.assertRaises(signing.BadSignature,
            request.get_signed_cookie, 'a', salt='two')
 </s> add         with self.assertRaises(signing.BadSignature):
            request.get_signed_cookie('a', salt='two') </s> remove         self.assertRaises(ImproperlyConfigured, get_user, request)
 </s> add         with self.assertRaises(ImproperlyConfigured):
            get_user(request)
        with self.assertRaises(PermissionDenied):
            a_view(request)
          def a_view(request):
              return HttpResponse()
          request = self.factory.get('/rand')
          request.user = self.user
        with self.assertRaises(PermissionDenied):
            a_view(request)
keep keep keep keep replace
 Refs #26022 -- Used context manager version of assertRaises in tests. 
tests/auth_tests/test_decorators.py