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
)
from graphene import signals
# from graphene import signals
from graphene.core.schema import (
Schema

View File

@ -53,16 +53,22 @@ class ObjectTypeMeta(type):
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.
for obj_name, obj in attrs.items():
new_class.add_to_class(obj_name, obj)
if new_class._meta.mutation:
assert hasattr(new_class, 'mutate'), "All mutations must implement mutate method"
Input = getattr(new_class, 'Input', None)
if Input:
input_type = type('{}Input'.format(new_class._meta.type_name), (Input, ObjectType), Input.__dict__)
setattr(new_class, 'input_type', input_type)
if input_class:
items = dict(input_class.__dict__)
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()

View File

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