Improved error messaging

This commit is contained in:
Syrus Akbary 2016-08-11 01:02:37 -07:00
parent feb8fb9b13
commit c4fba3b7ca
2 changed files with 3 additions and 3 deletions

View File

@ -61,8 +61,8 @@ class Field(OrderedType):
self._type = type self._type = type
self.args = args or OrderedDict() self.args = args or OrderedDict()
# self.args = to_arguments(args, extra_args) # self.args = to_arguments(args, extra_args)
assert not (source and resolver), ('You cannot provide a source and a ' assert not (source and resolver), ('A Field cannot have a source and a '
'resolver in a Field at the same time.') 'resolver in at the same time.')
if source: if source:
resolver = partial(source_resolver, source) resolver = partial(source_resolver, source)
self.resolver = resolver self.resolver = resolver

View File

@ -47,7 +47,7 @@ def test_field_not_source_and_resolver():
MyType = object() MyType = object()
with pytest.raises(Exception) as exc_info: with pytest.raises(Exception) as exc_info:
Field(MyType, source='value', resolver=lambda: None) Field(MyType, source='value', resolver=lambda: None)
assert str(exc_info.value) == 'You cannot provide a source and a resolver in a Field at the same time.' assert str(exc_info.value) == 'A Field cannot have a source and a resolver in at the same time.'
def test_field_source_func(): def test_field_source_func():
MyType = object() MyType = object()