def wait_for_assertion(assertion_expression, timeout=5):
 start_time = time.time()
 while ((time.time() - start_time) < timeout):
  try:
   return assertion_expression()
  except AssertionError:
   time.sleep(0.1)
 return assertion_expression()

def wait_for_assertion ( assertion_expression , timeout = 5 ) : start_time = time . time ( ) while ( ( time . time ( ) - start_time ) < timeout ) : try : return assertion_expression ( ) except AssertionError : time . sleep ( 0.1 ) return assertion_expression ( )
calls an assertion_expression repeatedly .