mirror of
https://github.com/graphql-python/graphene.git
synced 2025-07-27 08:19:45 +03:00
Merge 886ceb77b2
into 17ba01570a
This commit is contained in:
commit
a4f6bc08a8
|
@ -80,7 +80,7 @@ class ObjectType(six.with_metaclass(ObjectTypeMeta, FieldsClassType)):
|
||||||
if kwargs:
|
if kwargs:
|
||||||
for prop in list(kwargs):
|
for prop in list(kwargs):
|
||||||
try:
|
try:
|
||||||
if isinstance(getattr(self.__class__, prop), property):
|
if isinstance(getattr(self.__class__, prop), property) or prop.startswith('_'):
|
||||||
setattr(self, prop, kwargs.pop(prop))
|
setattr(self, prop, kwargs.pop(prop))
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
pass
|
pass
|
||||||
|
|
|
@ -55,6 +55,17 @@ def test_object_type_set_properties():
|
||||||
assert h.write_prop == 'custom'
|
assert h.write_prop == 'custom'
|
||||||
|
|
||||||
|
|
||||||
|
def test_object_type_set_private_attributes():
|
||||||
|
class Human(ObjectType):
|
||||||
|
_private_state = None
|
||||||
|
|
||||||
|
h = Human(_private_state='custom')
|
||||||
|
assert h._private_state == 'custom'
|
||||||
|
|
||||||
|
with raises(TypeError):
|
||||||
|
Human(_other_private_state='My name')
|
||||||
|
|
||||||
|
|
||||||
def test_object_type_container_invalid_kwarg():
|
def test_object_type_container_invalid_kwarg():
|
||||||
class Human(ObjectType):
|
class Human(ObjectType):
|
||||||
name = String()
|
name = String()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user