test: Format predicate source as multiline on error

Github-Pull: #15990
Rebased-From: fa3872e7b4
This commit is contained in:
MarcoFalke
2019-05-09 10:36:53 -04:00
parent 9c1a607a09
commit 8f215c7a27

View File

@@ -219,7 +219,7 @@ def wait_until(predicate, *, attempts=float('inf'), timeout=float('inf'), lock=N
time.sleep(0.05)
# Print the cause of the timeout
predicate_source = inspect.getsourcelines(predicate)
predicate_source = "''''\n" + inspect.getsource(predicate) + "'''"
logger.error("wait_until() failed. Predicate: {}".format(predicate_source))
if attempt >= attempts:
raise AssertionError("Predicate {} not true after {} attempts".format(predicate_source, attempts))