Skip to content

Commit

Permalink
Improve error message for attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
Zac-HD committed Jun 24, 2018
1 parent 0fc9b74 commit e12ab35
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions hypothesis-python/src/hypothesis/searchstrategy/attrs.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def from_attrs(target, args, kwargs, to_infer):
fields = attr.fields(target)
kwargs = {k: v for k, v in kwargs.items() if v is not infer}
for name in to_infer:
kwargs[name] = from_attrs_attribute(getattr(fields, name))
kwargs[name] = from_attrs_attribute(getattr(fields, name), target)
# We might make this strategy more efficient if we added a layer here that
# retries drawing if validation fails, for improved composition.
# The treatment of timezones in datetimes() provides a precedent.
Expand All @@ -43,7 +43,7 @@ def from_attrs(target, args, kwargs, to_infer):
)


def from_attrs_attribute(attrib):
def from_attrs_attribute(attrib, target):
"""Infer a strategy from the metadata on an attr.Attribute object."""
# Try inferring from the default argument. Note that this will only help
# the user passed `infer` to builds() for this attribute, but in that case
Expand Down Expand Up @@ -93,8 +93,8 @@ def from_attrs_attribute(attrib):
# when we try to get a value but have lost track of where this was created.
if strat.is_empty:
raise ResolutionFailed(
'Cannot infer a strategy from the default, vaildator, type, or '
'converter for %r' % (attrib,))
'Cannot infer a strategy from the default, validator, type, or '
'converter for attribute=%r of class=%r' % (attrib, target))
return strat


Expand Down

0 comments on commit e12ab35

Please sign in to comment.