Skip to content

Commit 8fbadee

Browse files
author
Sebastian Hernandez
committed
Update test to a more real case scenario
1 parent aed2f78 commit 8fbadee

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

graphene_django/tests/test_query.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,21 +1590,22 @@ class Query(graphene.ObjectType):
15901590

15911591

15921592
def test_should_query_django_objecttype_fields_custom_meta():
1593-
class ArticleTypeOptions(DjangoObjectTypeOptions):
1594-
"""Article Type Options with extra fields"""
1595-
1596-
fields = yank_fields_from_attrs(
1597-
{"headline_with_lang": graphene.String()}, _as=graphene.Field,
1598-
)
1599-
16001593
class ArticleBaseType(DjangoObjectType):
16011594
class Meta:
16021595
abstract = True
16031596

16041597
@classmethod
1605-
def __init_subclass_with_meta__(cls, **options):
1606-
options.setdefault("_meta", ArticleTypeOptions(cls))
1607-
super(ArticleBaseType, cls).__init_subclass_with_meta__(**options)
1598+
def __init_subclass_with_meta__(cls, _meta=None, **options):
1599+
if _meta is None:
1600+
_meta = DjangoObjectTypeOptions(cls)
1601+
1602+
_meta.fields = yank_fields_from_attrs(
1603+
{"headline_with_lang": graphene.String()}, _as=graphene.Field,
1604+
)
1605+
1606+
super(ArticleBaseType, cls).__init_subclass_with_meta__(
1607+
_meta=_meta, **options
1608+
)
16081609

16091610
class ArticleCustomType(ArticleBaseType):
16101611
class Meta:

0 commit comments

Comments
 (0)