Revision: 3840
Author: jprantan
Date: Wed Aug 18 04:02:26 2010
Log: Changed teardown to continue execution in case of syntax error. Issue
615.
http://code.google.com/p/robotframework/source/detail?r=3840
Modified:
/trunk/src/robot/errors.py
/trunk/src/robot/running/context.py
/trunk/src/robot/running/keywords.py
=======================================
--- /trunk/src/robot/errors.py Mon Jul 12 13:03:19 2010
+++ /trunk/src/robot/errors.py Wed Aug 18 04:02:26 2010
@@ -89,12 +89,12 @@
cont = property(lambda self: self._cont and not self.dont_cont,
lambda self, cont: setattr(self, '_cont', cont))
- def can_continue(self, dry_run=False, templated=False):
+ def can_continue(self, teardown=False, templated=False, dry_run=False):
if dry_run:
return True
- if self.dont_cont:
+ if self.dont_cont and not (teardown and self.syntax):
return False
- if templated:
+ if teardown or templated:
return True
return self.cont
@@ -104,13 +104,12 @@
class HandlerExecutionFailed(ExecutionFailed):
- def __init__(self, error_details, is_test_or_suite_teardown):
+ def __init__(self, error_details):
orig_error = error_details.error
timeout = isinstance(orig_error, TimeoutError)
syntax = isinstance(orig_error, DataError)
exit = bool(getattr(orig_error, 'ROBOT_EXIT_ON_FAILURE', False))
- cont = bool(getattr(orig_error, 'ROBOT_CONTINUE_ON_FAILURE',
False)) \
- or is_test_or_suite_teardown
+ cont = bool(getattr(orig_error, 'ROBOT_CONTINUE_ON_FAILURE',
False))
ExecutionFailed.__init__(self, error_details.message, timeout,
syntax,
exit, cont)
=======================================
--- /trunk/src/robot/running/context.py Mon May 31 05:21:54 2010
+++ /trunk/src/robot/running/context.py Wed Aug 18 04:02:26 2010
@@ -22,6 +22,11 @@
self.output = output
self.dry_run = dry_run
+ @property
+ def teardown(self):
+ test_or_suite = self.namespace.test or self.namespace.suite
+ return test_or_suite.status != 'RUNNING'
+
def get_current_vars(self):
return self.namespace.variables
=======================================
--- /trunk/src/robot/running/keywords.py Mon Jul 12 13:03:19 2010
+++ /trunk/src/robot/running/keywords.py Wed Aug 18 04:02:26 2010
@@ -45,7 +45,8 @@
kw.run(context)
except ExecutionFailed, err:
errors.extend(err.get_errors())
- if not err.can_continue(context.dry_run, self._templated):
+ if not err.can_continue(context.teardown, self._templated,
+ context.dry_run):
break
if errors:
raise ExecutionFailures(errors)
@@ -109,7 +110,7 @@
self.endtime = utils.get_timestamp()
self.elapsedtime = utils.get_elapsed_time(self.starttime,
self.endtime)
try:
- if not error or error.cont:
+ if not error or error.can_continue(context.teardown):
self._set_variables(context, return_value)
finally:
context.end_keyword(self)
@@ -128,12 +129,7 @@
context.output.fail(error_details.message)
if error_details.traceback:
context.output.debug(error_details.traceback)
- is_teardown = self._in_test_or_suite_teardown(context.namespace)
- raise HandlerExecutionFailed(error_details, is_teardown)
-
- def _in_test_or_suite_teardown(self, namespace):
- test_or_suite = namespace.test or namespace.suite
- return test_or_suite.status != 'RUNNING'
+ raise HandlerExecutionFailed(error_details)
class _VariableAssigner(object):
@@ -295,7 +291,8 @@
err = self._run_one_round(context, self.vars, values)
if err:
errors.extend(err.get_errors())
- if not err.can_continue(context.dry_run, self._templated):
+ if not err.can_continue(context.teardown, self._templated,
+ context.dry_run):
break
if errors:
raise ExecutionFailures(errors)