def serialize_fully(): index = 0 while index < len(serialize_me): for field in get_fields(serialize_me[index]): if isinstance(field, models.ForeignKey): add_to_serialize_list( [serialize_me[index].__getattribute__(field.name)]) index += 1 serialize_me.reverse()
def test_get_fields(self): obj = lambda: None obj._meta = lambda: None obj._meta.fields = ['foo'] self.assertEqual(['foo'], get_fields(obj))