Skip to content

Commit

Permalink
Fix type name of FieldInfo namedtuple (#9124)
Browse files Browse the repository at this point in the history
* Fix type name of `FieldInfo` namedtuple

* Add test
  • Loading branch information
Viicos authored Oct 4, 2023
1 parent 605cc4f commit d32346b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rest_framework/utils/model_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"""
from collections import namedtuple

FieldInfo = namedtuple('FieldResult', [
FieldInfo = namedtuple('FieldInfo', [
'pk', # Model field instance
'fields', # Dict of field name -> model field instance
'forward_relations', # Dict of field name -> RelationInfo
Expand Down
7 changes: 7 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from rest_framework.utils import json
from rest_framework.utils.breadcrumbs import get_breadcrumbs
from rest_framework.utils.formatting import lazy_format
from rest_framework.utils.model_meta import FieldInfo, RelationInfo
from rest_framework.utils.urls import remove_query_param, replace_query_param
from rest_framework.views import APIView
from rest_framework.viewsets import ModelViewSet
Expand Down Expand Up @@ -267,3 +268,9 @@ def test_it_formats_lazily(self):
assert message.format.call_count == 1
str(formatted)
assert message.format.call_count == 1


class ModelMetaNamedTupleNames(TestCase):
def test_named_tuple_names(self):
assert FieldInfo.__name__ == 'FieldInfo'
assert RelationInfo.__name__ == 'RelationInfo'

0 comments on commit d32346b

Please sign in to comment.