Skip to content

Commit

Permalink
Reformatted code
Browse files Browse the repository at this point in the history
  • Loading branch information
syrusakbary committed Mar 14, 2020
1 parent 34560ca commit 05d08df
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
1 change: 1 addition & 0 deletions graphene/types/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ def __repr__(self):

BaseTypeMeta = SubclassWithMeta_Meta


class BaseType(SubclassWithMeta):
@classmethod
def create_type(cls, class_name, **options):
Expand Down
12 changes: 10 additions & 2 deletions graphene/types/objecttype.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,18 @@ def __new__(cls, name, bases, namespace):
class InterObjectType:
pass

base_cls = super().__new__(cls, name, (InterObjectType, ) + bases, namespace)
base_cls = super().__new__(cls, name, (InterObjectType,) + bases, namespace)
if base_cls._meta:
fields = [
(key, 'typing.Any', field(default=field_value.default_value if isinstance(field_value, Field) else None))
(
key,
"typing.Any",
field(
default=field_value.default_value
if isinstance(field_value, Field)
else None
),
)
for key, field_value in base_cls._meta.fields.items()
]
dataclass = make_dataclass(name, fields, bases=())
Expand Down
7 changes: 6 additions & 1 deletion graphene/types/tests/test_objecttype.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,12 @@ def test_objecttype_as_container_only_args():
assert container.field1 == "1"
assert container.field2 == "2"


def test_objecttype_repr():
container = Container("1", "2")
assert repr(container) == "Container(field1='1', field2='2')"


def test_objecttype_eq():
container1 = Container("1", "2")
container2 = Container("1", "2")
Expand All @@ -170,6 +172,7 @@ def test_objecttype_eq():
assert container1 == container2
assert container2 != container3


def test_objecttype_as_container_args_kwargs():
container = Container("1", field2="2")
assert container.field1 == "1"
Expand All @@ -191,7 +194,9 @@ def test_objecttype_as_container_extra_args():
with raises(TypeError) as excinfo:
Container("1", "2", "3")

assert "__init__() takes from 1 to 3 positional arguments but 4 were given" == str(excinfo.value)
assert "__init__() takes from 1 to 3 positional arguments but 4 were given" == str(
excinfo.value
)


def test_objecttype_as_container_invalid_kwargs():
Expand Down

0 comments on commit 05d08df

Please sign in to comment.