mirror of
https://github.com/graphql-python/graphene.git
synced 2025-07-26 07:49:53 +03:00
Added __str__ to object type.
This commit is contained in:
parent
8e320da051
commit
9a69cf9413
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -75,6 +75,7 @@ target/
|
|||
|
||||
# PyCharm
|
||||
.idea
|
||||
*.iml
|
||||
|
||||
# Databases
|
||||
*.sqlite3
|
||||
|
|
|
@ -3,6 +3,7 @@ from collections import OrderedDict
|
|||
import six
|
||||
|
||||
from ..utils.is_base_type import is_base_type
|
||||
from ..pyutils.type_to_string import object_type_to_string
|
||||
from .abstracttype import AbstractTypeMeta
|
||||
from .interface import Interface
|
||||
from .options import Options
|
||||
|
@ -106,3 +107,9 @@ class ObjectType(six.with_metaclass(ObjectTypeMeta)):
|
|||
self.__class__.__name__
|
||||
)
|
||||
)
|
||||
|
||||
def __repr__(self):
|
||||
return object_type_to_string(self, full_package_name=True)
|
||||
|
||||
def __str__(self):
|
||||
return object_type_to_string(self)
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
from mock import patch, call
|
||||
import pytest
|
||||
|
||||
from ..abstracttype import AbstractType
|
||||
|
@ -173,3 +174,17 @@ def test_objecttype_container_benchmark(benchmark):
|
|||
@benchmark
|
||||
def create_objecttype():
|
||||
Container(field1='field1', field2='field2')
|
||||
|
||||
|
||||
@patch('graphene.types.objecttype.object_type_to_string', return_value='')
|
||||
def test_repr_calls_right_implementation(mock_impl):
|
||||
c1 = Container()
|
||||
repr(c1)
|
||||
assert mock_impl.call_count == 1
|
||||
|
||||
|
||||
@patch('graphene.types.objecttype.object_type_to_string', return_value='')
|
||||
def test_str_calls_right_implementation(mock_impl):
|
||||
c1 = Container()
|
||||
str(c1)
|
||||
assert mock_impl.call_count == 1
|
||||
|
|
Loading…
Reference in New Issue
Block a user