  
  class DecoratorTestCase(TestCase):
  
      def setUp(self):
          self.factory = RequestFactory()
  
      def _finalize_response(self, request, response, *args, **kwargs):
          response.request = request
          return APIView.finalize_response(self, request, response, *args, **kwargs)
  
 
</s> remove factory = RequestFactory()
 </s> add factory = DRFRequestFactory() </s> remove     # def test_calling_patch_method(self):
 </s> add     def test_calling_patch_method(self): </s> remove     #     @api_view(['GET', 'PATCH'])
    #     def view(request):
    #         return Response({})
 </s> add         @api_view(['GET', 'PATCH'])
        def view(request):
            return Response({}) </s> remove     #     request = self.factory.patch('/')
    #     response = view(request)
    #     self.assertEqual(response.status_code, 200)
 </s> add         request = self.factory.patch('/')
        response = view(request)
        self.assertEqual(response.status_code, 200)
        self.factory = DRFRequestFactory()
  
  class DecoratorTestCase(TestCase):
  
      def setUp(self):
        self.factory = DRFRequestFactory()
  
      def _finalize_response(self, request, response, *args, **kwargs):
          response.request = request
          return APIView.finalize_response(self, request, response, *args, **kwargs)
  
keep keep keep keep replace keep keep keep keep keep
 Adjust PATCH test cases to use the new DRFRequestFactory 
rest_framework/tests/decorators.py