graphql-python / graphene-django

Build powerful, efficient, and flexible GraphQL APIs with seamless Django integration.
http://docs.graphene-python.org/projects/django/en/latest/
MIT License
4.31k stars 769 forks source link

Test failures with djangorestframework 3.15.1 #1510

Closed mweinelt closed 8 months ago

mweinelt commented 8 months ago

Note: for support questions, please use stackoverflow. This repository's issues are reserved for feature requests and bug reports.

> FAILED graphene_django/rest_framework/tests/test_field_converter.py::test_should_filepath_convert_string - ValueError: not enough values to unpack (expected 2, got 0)
> FAILED graphene_django/rest_framework/tests/test_field_converter.py::test_should_choice_convert_enum - ValueError: not enough values to unpack (expected 2, got 1)
> FAILED graphene_django/rest_framework/tests/test_field_converter.py::test_should_multiplechoicefield_convert_to_list_of_enum - TypeError: cannot unpack non-iterable int object
> FAILED graphene_django/rest_framework/tests/test_mutation.py::test_perform_mutate_success_with_enum_choice_field - ValueError: too many values to unpack (expected 2)

Upgrade djangorestframework to 3.15.1 and run the test suite

Test suite should complete with drf 3.15.1.

https://github.com/graphql-python/graphene-django/blob/45c2aa09b5bf56a19ce383aa9effd14072acb500/setup.py#L13

n/a

graphene-django> _____________________ test_should_filepath_convert_string ______________________
graphene-django> 
graphene-django>     def test_should_filepath_convert_string():
graphene-django> >       assert_conversion(serializers.FilePathField, graphene.Enum, path="/")
graphene-django> 
graphene-django> graphene_django/rest_framework/tests/test_field_converter.py:200: 
graphene-django> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
graphene-django> graphene_django/rest_framework/tests/test_field_converter.py:32: in assert_conversion
graphene-django>     graphene_type = _get_type(
graphene-django> graphene_django/rest_framework/tests/test_field_converter.py:26: in _get_type
graphene-django>     return convert_serializer_field(
graphene-django> graphene_django/rest_framework/serializer_converter.py:33: in convert_serializer_field
graphene-django>     graphql_type = get_graphene_type_from_serializer_field(field)
graphene-django> /nix/store/pfm87s95hzfvb28s125zb3sfbfckca47-python3-3.11.8/lib/python3.11/functools.py:909: in wrapper
graphene-django>     return dispatch(args[0].__class__)(*args, **kw)
graphene-django> graphene_django/rest_framework/serializer_converter.py:168: in convert_serializer_field_to_enum
graphene-django>     return convert_choices_to_named_enum_with_descriptions(name, field.choices)
graphene-django> graphene_django/converter.py:92: in convert_choices_to_named_enum_with_descriptions
graphene-django>     choices = list(get_choices(choices))
graphene-django> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
graphene-django> 
graphene-django> choices = {'': '---------'}
graphene-django> 
graphene-django>     def get_choices(choices):
graphene-django>         converted_names = []
graphene-django>         if isinstance(choices, OrderedDict):
graphene-django>             choices = choices.items()
graphene-django> >       for value, help_text in choices:
graphene-django> E       ValueError: not enough values to unpack (expected 2, got 0)
graphene-django> 
graphene-django> graphene_django/converter.py:77: ValueError
graphene-django> _______________________ test_should_choice_convert_enum ________________________
graphene-django> 
graphene-django>     def test_should_choice_convert_enum():
graphene-django> >       field = assert_conversion(
graphene-django>             serializers.ChoiceField,
graphene-django>             graphene.Enum,
graphene-django>             choices=[("h", "Hello"), ("w", "World")],
graphene-django>             source="word",
graphene-django>         )
graphene-django> 
graphene-django> graphene_django/rest_framework/tests/test_field_converter.py:68: 
graphene-django> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
graphene-django> graphene_django/rest_framework/tests/test_field_converter.py:32: in assert_conversion
graphene-django>     graphene_type = _get_type(
graphene-django> graphene_django/rest_framework/tests/test_field_converter.py:26: in _get_type
graphene-django>     return convert_serializer_field(
graphene-django> graphene_django/rest_framework/serializer_converter.py:33: in convert_serializer_field
graphene-django>     graphql_type = get_graphene_type_from_serializer_field(field)
graphene-django> /nix/store/pfm87s95hzfvb28s125zb3sfbfckca47-python3-3.11.8/lib/python3.11/functools.py:909: in wrapper
graphene-django>     return dispatch(args[0].__class__)(*args, **kw)
graphene-django> graphene_django/rest_framework/serializer_converter.py:168: in convert_serializer_field_to_enum
graphene-django>     return convert_choices_to_named_enum_with_descriptions(name, field.choices)
graphene-django> graphene_django/converter.py:92: in convert_choices_to_named_enum_with_descriptions
graphene-django>     choices = list(get_choices(choices))
graphene-django> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
graphene-django> 
graphene-django> choices = {'h': 'Hello', 'w': 'World'}
graphene-django> 
graphene-django>     def get_choices(choices):
graphene-django>         converted_names = []
graphene-django>         if isinstance(choices, OrderedDict):
graphene-django>             choices = choices.items()
graphene-django> >       for value, help_text in choices:
graphene-django> E       ValueError: not enough values to unpack (expected 2, got 1)
graphene-django> 
graphene-django> graphene_django/converter.py:77: ValueError
graphene-django> ___________ test_should_multiplechoicefield_convert_to_list_of_enum ____________
graphene-django> 
graphene-django>     def test_should_multiplechoicefield_convert_to_list_of_enum():
graphene-django> >       field = assert_conversion(
graphene-django>             serializers.MultipleChoiceField, graphene.List, choices=[1, 2, 3]
graphene-django>         )
graphene-django> 
graphene-django> graphene_django/rest_framework/tests/test_field_converter.py:216: 
graphene-django> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
graphene-django> graphene_django/rest_framework/tests/test_field_converter.py:32: in assert_conversion
graphene-django>     graphene_type = _get_type(
graphene-django> graphene_django/rest_framework/tests/test_field_converter.py:26: in _get_type
graphene-django>     return convert_serializer_field(
graphene-django> graphene_django/rest_framework/serializer_converter.py:33: in convert_serializer_field
graphene-django>     graphql_type = get_graphene_type_from_serializer_field(field)
graphene-django> /nix/store/pfm87s95hzfvb28s125zb3sfbfckca47-python3-3.11.8/lib/python3.11/functools.py:909: in wrapper
graphene-django>     return dispatch(args[0].__class__)(*args, **kw)
graphene-django> graphene_django/rest_framework/serializer_converter.py:160: in convert_serializer_field_to_list_of_enum
graphene-django>     child_type = convert_serializer_field_to_enum(field)
graphene-django> graphene_django/rest_framework/serializer_converter.py:168: in convert_serializer_field_to_enum
graphene-django>     return convert_choices_to_named_enum_with_descriptions(name, field.choices)
graphene-django> graphene_django/converter.py:92: in convert_choices_to_named_enum_with_descriptions
graphene-django>     choices = list(get_choices(choices))
graphene-django> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
graphene-django> 
graphene-django> choices = {1: 1, 2: 2, 3: 3}
graphene-django> 
graphene-django>     def get_choices(choices):
graphene-django>         converted_names = []
graphene-django>         if isinstance(choices, OrderedDict):
graphene-django>             choices = choices.items()
graphene-django> >       for value, help_text in choices:
graphene-django> E       TypeError: cannot unpack non-iterable int object
graphene-django> 
graphene-django> graphene_django/converter.py:77: TypeError
graphene-django> ______________ test_perform_mutate_success_with_enum_choice_field ______________
graphene-django> 
graphene-django>     def test_perform_mutate_success_with_enum_choice_field():
graphene-django>         class ListViewChoiceFieldSerializer(serializers.ModelSerializer):
graphene-django>             choice_type = serializers.ChoiceField(
graphene-django>                 choices=[(x.name, x.value) for x in MyFakeModelWithChoiceField.ChoiceType],
graphene-django>                 required=False,
graphene-django>             )
graphene-django>     
graphene-django>             class Meta:
graphene-django>                 model = MyFakeModelWithChoiceField
graphene-django>                 fields = "__all__"
graphene-django>     
graphene-django> >       class SomeCreateSerializerMutation(SerializerMutation):
graphene-django> 
graphene-django> graphene_django/rest_framework/tests/test_mutation.py:297: 
graphene-django> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
graphene-django> /nix/store/f080sndvm4vrwdkz7fgq834zddhlx6dq-python3.11-graphene-3.3.0/lib/python3.11/site-packages/graphene/types/objecttype.py:30: in __new__
graphene-django>     base_cls = super().__new__(
graphene-django> /nix/store/f080sndvm4vrwdkz7fgq834zddhlx6dq-python3.11-graphene-3.3.0/lib/python3.11/site-packages/graphene/utils/subclass_with_meta.py:46: in __init_subclass__
graphene-django>     super_class.__init_subclass_with_meta__(**options)
graphene-django> graphene_django/rest_framework/mutation.py:101: in __init_subclass_with_meta__
graphene-django>     input_fields = fields_for_serializer(
graphene-django> graphene_django/rest_framework/mutation.py:55: in fields_for_serializer
graphene-django>     fields[name] = convert_serializer_field(
graphene-django> graphene_django/rest_framework/serializer_converter.py:33: in convert_serializer_field
graphene-django>     graphql_type = get_graphene_type_from_serializer_field(field)
graphene-django> /nix/store/pfm87s95hzfvb28s125zb3sfbfckca47-python3-3.11.8/lib/python3.11/functools.py:909: in wrapper
graphene-django>     return dispatch(args[0].__class__)(*args, **kw)
graphene-django> graphene_django/rest_framework/serializer_converter.py:168: in convert_serializer_field_to_enum
graphene-django>     return convert_choices_to_named_enum_with_descriptions(name, field.choices)
graphene-django> graphene_django/converter.py:92: in convert_choices_to_named_enum_with_descriptions
graphene-django>     choices = list(get_choices(choices))
graphene-django> _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
graphene-django> 
graphene-django> choices = {'ASDF': 'asdf', 'HI': 'hi'}
graphene-django> 
graphene-django>     def get_choices(choices):
graphene-django>         converted_names = []
graphene-django>         if isinstance(choices, OrderedDict):
graphene-django>             choices = choices.items()
graphene-django> >       for value, help_text in choices:
graphene-django> E       ValueError: too many values to unpack (expected 2)
graphene-django> 
graphene-django> graphene_django/converter.py:77: ValueError
MrThearMan commented 8 months ago

Duplicate issue: #1507. This was fixed by #1506, but there is no patch out in PyPI.