Merge pull request #4632 from AnjoMan/dont-rewrite-objects-with-failing-getattr

Assertion rewrite breaks for objects that reimplement `__getattr__`
This commit is contained in:
Bruno Oliveira
2019-01-11 14:07:22 -02:00
committed by GitHub
4 changed files with 30 additions and 1 deletions

View File

@@ -525,7 +525,13 @@ def _format_assertmsg(obj):
def _should_repr_global_name(obj):
return not hasattr(obj, "__name__") and not callable(obj)
if callable(obj):
return False
try:
return not hasattr(obj, "__name__")
except Exception:
return True
def _format_boolop(explanations, is_or):