          # Include the CONTENT_TYPE, regardless of whether or not data is empty.
          if content_type is not None:
              extra['CONTENT_TYPE'] = str(content_type)
  
          return super(APIRequestFactory, self).generic(
              method, path, data, content_type, secure, **extra)
  
      def request(self, **kwargs):
          request = super(APIRequestFactory, self).request(**kwargs)
          request._dont_enforce_csrf_checks = not self.enforce_csrf_checks
 
</s> remove         request = super(APIRequestFactory, self).request(**kwargs)
 </s> add         request = super().request(**kwargs) </s> remove         super(APIRequestFactory, self).__init__(**defaults)
 </s> add         super().__init__(**defaults) </s> remove         context = super(AdminRenderer, self).get_context(
 </s> add         context = super().get_context( </s> remove             content_type = "{0}; charset={1}".format(media_type, charset)
 </s> add             content_type = "{}; charset={}".format(media_type, charset) </s> remove         super(MethodNotAllowed, self).__init__(detail, code)
 </s> add         super().__init__(detail, code)
        return super().generic(
          # Include the CONTENT_TYPE, regardless of whether or not data is empty.
          if content_type is not None:
              extra['CONTENT_TYPE'] = str(content_type)
  
        return super().generic(
              method, path, data, content_type, secure, **extra)
  
      def request(self, **kwargs):
          request = super(APIRequestFactory, self).request(**kwargs)
          request._dont_enforce_csrf_checks = not self.enforce_csrf_checks
keep keep keep keep replace keep keep keep keep keep
 Dropped Python 2 compatibility. (#6615)

Thanks to Jon Dufresne (@jdufresne) for review.

Co-authored-by: Asif Saif Uddin <auvipy@gmail.com>
Co-authored-by: Rizwan Mansuri <Rizwan@webbyfox.com> 
rest_framework/test.py