Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test failures with djangorestframework 3.15.1 #1510

Closed
mweinelt opened this issue Mar 24, 2024 · 1 comment
Closed

Test failures with djangorestframework 3.15.1 #1510

mweinelt opened this issue Mar 24, 2024 · 1 comment
Labels

Comments

@mweinelt
Copy link

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

  • What is the current behavior?
> 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

  • What is the expected behavior?

Test suite should complete with drf 3.15.1.

rest_framework_require = ["djangorestframework>=3.6.3"]

  • What is the motivation / use case for changing the behavior?

n/a

  • Please tell us about your environment:

    • Version: 3.2.0
    • Platform: Linux
  • Other information (e.g. detailed explanation, stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow)

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants