Commit 463d6a03 authored by Vincent Pelletier's avatar Vincent Pelletier

Add a callback triggered right before handling condition timeout.

This allows automating tasks right before test fails (for example, dumping
database state) for later inspection.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@1665 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 7331764e
......@@ -368,7 +368,7 @@ class NEOCluster(object):
current_try = None
return current_try
def expectCondition(self, condition, timeout=0, delay=1):
def expectCondition(self, condition, timeout=0, delay=1, on_fail=None):
end = time.time() + timeout + DELAY_SAFETY_MARGIN
opaque = None
opaque_history = []
......@@ -380,6 +380,8 @@ class NEOCluster(object):
opaque_history.append(opaque)
time.sleep(delay)
else:
if on_fail is not None:
on_fail(opaque_history)
raise AssertionError, 'Timeout while expecting condition. ' \
'History: %s' % (opaque_history, )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment