                  "Invalid format '{0}'. Available formats are {1}. "
                  "Set TEST_REQUEST_RENDERER_CLASSES to enable "
                  "extra request formats.".format(
                      format,
                      ', '.join(["'" + fmt + "'" for fmt in self.renderer_classes.keys()])
                  )
              )
  
              # Use format and render the data into a bytestring
              renderer = self.renderer_classes[format]()
 
</s> remove             list(self.Meta.model._meta.parents.keys())
 </s> add             list(self.Meta.model._meta.parents) </s> remove         for parent_class in [model] + list(model._meta.parents.keys()):
 </s> add         for parent_class in [model] + list(model._meta.parents): </s> remove             list(declared_fields.keys()) +
            list(model_info.fields.keys()) +
            list(model_info.forward_relations.keys())
 </s> add             list(declared_fields) +
            list(model_info.fields) +
            list(model_info.forward_relations) </s> remove             list(declared_fields.keys()) +
            list(model_info.fields.keys()) +
            list(model_info.forward_relations.keys())
 </s> add             list(declared_fields) +
            list(model_info.fields) +
            list(model_info.forward_relations) </s> remove         assert set(serializer.data.keys()) == {'name', 'ref'}
 </s> add         assert set(serializer.data) == {'name', 'ref'}
                    ', '.join(["'" + fmt + "'" for fmt in self.renderer_classes])
                  "Invalid format '{0}'. Available formats are {1}. "
                  "Set TEST_REQUEST_RENDERER_CLASSES to enable "
                  "extra request formats.".format(
                      format,
                    ', '.join(["'" + fmt + "'" for fmt in self.renderer_classes])
                  )
              )
  
              # Use format and render the data into a bytestring
              renderer = self.renderer_classes[format]()
keep keep keep keep replace keep keep keep keep keep
 Perfer iter(dict) over iter(dict.keys()) (#5736)

Calling dict.keys() is unnecessary. The two are functionally equivalent
on modern Pythons.

Inspired by Lennart Regebro's talk "Prehistoric Patterns in Python" from
PyCon 2017.

https://www.youtube.com/watch?v=V5-JH23Vk0I 
rest_framework/test.py