Skip to content

Commit d32346b

Browse files
authored
Fix type name of FieldInfo namedtuple (#9124)
* Fix type name of `FieldInfo` namedtuple * Add test
1 parent 605cc4f commit d32346b

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

rest_framework/utils/model_meta.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"""
88
from collections import namedtuple
99

10-
FieldInfo = namedtuple('FieldResult', [
10+
FieldInfo = namedtuple('FieldInfo', [
1111
'pk', # Model field instance
1212
'fields', # Dict of field name -> model field instance
1313
'forward_relations', # Dict of field name -> RelationInfo

tests/test_utils.py

+7
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
from rest_framework.utils import json
1010
from rest_framework.utils.breadcrumbs import get_breadcrumbs
1111
from rest_framework.utils.formatting import lazy_format
12+
from rest_framework.utils.model_meta import FieldInfo, RelationInfo
1213
from rest_framework.utils.urls import remove_query_param, replace_query_param
1314
from rest_framework.views import APIView
1415
from rest_framework.viewsets import ModelViewSet
@@ -267,3 +268,9 @@ def test_it_formats_lazily(self):
267268
assert message.format.call_count == 1
268269
str(formatted)
269270
assert message.format.call_count == 1
271+
272+
273+
class ModelMetaNamedTupleNames(TestCase):
274+
def test_named_tuple_names(self):
275+
assert FieldInfo.__name__ == 'FieldInfo'
276+
assert RelationInfo.__name__ == 'RelationInfo'

0 commit comments

Comments
 (0)