From 8fbadee60c78ae1492640cc8eebd03b896c316ce Mon Sep 17 00:00:00 2001 From: Sebastian Hernandez Date: Tue, 23 Feb 2021 19:31:16 +0100 Subject: [PATCH] Update test to a more real case scenario --- graphene_django/tests/test_query.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/graphene_django/tests/test_query.py b/graphene_django/tests/test_query.py index 164e0bb..f94129d 100644 --- a/graphene_django/tests/test_query.py +++ b/graphene_django/tests/test_query.py @@ -1590,21 +1590,22 @@ def test_connection_should_allow_offset_filtering_with_after(): def test_should_query_django_objecttype_fields_custom_meta(): - class ArticleTypeOptions(DjangoObjectTypeOptions): - """Article Type Options with extra fields""" - - fields = yank_fields_from_attrs( - {"headline_with_lang": graphene.String()}, _as=graphene.Field, - ) - class ArticleBaseType(DjangoObjectType): class Meta: abstract = True @classmethod - def __init_subclass_with_meta__(cls, **options): - options.setdefault("_meta", ArticleTypeOptions(cls)) - super(ArticleBaseType, cls).__init_subclass_with_meta__(**options) + def __init_subclass_with_meta__(cls, _meta=None, **options): + if _meta is None: + _meta = DjangoObjectTypeOptions(cls) + + _meta.fields = yank_fields_from_attrs( + {"headline_with_lang": graphene.String()}, _as=graphene.Field, + ) + + super(ArticleBaseType, cls).__init_subclass_with_meta__( + _meta=_meta, **options + ) class ArticleCustomType(ArticleBaseType): class Meta: