mirror of
https://github.com/graphql-python/graphene.git
synced 2025-07-18 03:52:24 +03:00
Added repr and eq methods to ObjectType containers
This commit is contained in:
parent
2b3356fd98
commit
34560ca5b3
|
@ -33,6 +33,8 @@ class ObjectTypeMeta(BaseTypeMeta):
|
|||
]
|
||||
dataclass = make_dataclass(name, fields, bases=())
|
||||
InterObjectType.__init__ = dataclass.__init__
|
||||
InterObjectType.__eq__ = dataclass.__eq__
|
||||
InterObjectType.__repr__ = dataclass.__repr__
|
||||
return base_cls
|
||||
|
||||
|
||||
|
|
|
@ -158,6 +158,17 @@ 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")
|
||||
container3 = Container("2", "3")
|
||||
assert container1 == container1
|
||||
assert container1 == container2
|
||||
assert container2 != container3
|
||||
|
||||
def test_objecttype_as_container_args_kwargs():
|
||||
container = Container("1", field2="2")
|
||||
|
|
Loading…
Reference in New Issue
Block a user