mirror of
https://github.com/graphql-python/graphene.git
synced 2024-11-23 01:56:54 +03:00
Improved Python3 compat
This commit is contained in:
parent
145183d0ae
commit
ccfed3df3f
|
@ -15,7 +15,6 @@ except ImportError:
|
|||
from ..utils.enum import Enum as PyEnum
|
||||
|
||||
|
||||
|
||||
class GrapheneEnumType(GrapheneGraphQLType, GraphQLEnumType):
|
||||
pass
|
||||
|
||||
|
@ -61,6 +60,9 @@ class EnumTypeMeta(type):
|
|||
|
||||
return cls
|
||||
|
||||
def __prepare__(name, bases, **kwargs):
|
||||
return OrderedDict()
|
||||
|
||||
def __call__(cls, *args, **kwargs):
|
||||
if cls is Enum:
|
||||
return cls.from_enum(PyEnum(*args, **kwargs))
|
||||
|
|
|
@ -95,7 +95,7 @@ class Field(AbstractField, GraphQLField, OrderedType):
|
|||
# break
|
||||
|
||||
if resolver:
|
||||
resolver = resolver.__func__
|
||||
resolver = getattr(resolver, '__func__', resolver)
|
||||
else:
|
||||
resolver = self.default_resolver
|
||||
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
from graphql.type import GraphQLEnumType, GraphQLEnumValue
|
||||
|
||||
from ...utils.enum import Enum as PyEnum
|
||||
from ..argument import Argument
|
||||
from ..enum import Enum
|
||||
from ..enum import Enum, PyEnum
|
||||
from ..field import Field
|
||||
|
||||
|
||||
|
|
|
@ -8,13 +8,13 @@ from ..get_fields import get_fields_from_attrs, get_fields_from_types
|
|||
|
||||
|
||||
def test_get_fields_from_attrs():
|
||||
attrs = {
|
||||
'field_string': Field(String),
|
||||
'string': String(),
|
||||
'other': None,
|
||||
'argument': Argument(String),
|
||||
'graphql_field': GraphQLField(GraphQLString)
|
||||
}
|
||||
attrs = OrderedDict((
|
||||
('field_string', Field(String)),
|
||||
('string', String()),
|
||||
('other', None),
|
||||
('argument', Argument(String)),
|
||||
('graphql_field', GraphQLField(GraphQLString)),
|
||||
))
|
||||
extracted_fields = OrderedDict(get_fields_from_attrs(ObjectType, attrs))
|
||||
assert [f for f in extracted_fields.keys()] == ['field_string', 'string']
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user