Fixed Python3 errors

This commit is contained in:
Syrus Akbary 2015-10-25 22:34:37 -07:00
parent bc3d176b4e
commit b377eb6230
3 changed files with 12 additions and 6 deletions

View File

@ -6,7 +6,7 @@ from graphql.core.type import (
GraphQLID as ID GraphQLID as ID
) )
from graphene import signals # from graphene import signals
from graphene.core.schema import ( from graphene.core.schema import (
Schema Schema

View File

@ -53,16 +53,22 @@ class ObjectTypeMeta(type):
assert not (new_class._meta.interface and new_class._meta.mutation) assert not (new_class._meta.interface and new_class._meta.mutation)
input_class = None
if new_class._meta.mutation:
input_class = attrs.pop('Input', None)
# Add all attributes to the class. # Add all attributes to the class.
for obj_name, obj in attrs.items(): for obj_name, obj in attrs.items():
new_class.add_to_class(obj_name, obj) new_class.add_to_class(obj_name, obj)
if new_class._meta.mutation: if new_class._meta.mutation:
assert hasattr(new_class, 'mutate'), "All mutations must implement mutate method" assert hasattr(new_class, 'mutate'), "All mutations must implement mutate method"
Input = getattr(new_class, 'Input', None)
if Input: if input_class:
input_type = type('{}Input'.format(new_class._meta.type_name), (Input, ObjectType), Input.__dict__) items = dict(input_class.__dict__)
setattr(new_class, 'input_type', input_type) items.pop('__dict__', None)
input_type = type('{}Input'.format(new_class._meta.type_name), (ObjectType, ), items)
new_class.add_to_class('input_type', input_type)
new_class.add_extra_fields() new_class.add_extra_fields()

View File

@ -14,7 +14,7 @@ deps=
setenv = setenv =
PYTHONPATH = .:{envdir} PYTHONPATH = .:{envdir}
commands= commands=
py.test py.test tests/
[pytest] [pytest]
DJANGO_SETTINGS_MODULE = tests.django_settings DJANGO_SETTINGS_MODULE = tests.django_settings