feat(try-except): dry run except branches
@@ -22,7 +22,7 @@ from robot.errors import (ExecutionFailed, ExecutionFailures, ExecutionPassed,
from robot.result import (For as ForResult, If as IfResult, IfBranch as IfBranchResult,
Try as TryResult, Except as ExceptResult)
from robot.output import librarylogger as logger
-from robot.utils import (cut_assign_value, frange, get_error_message,
+from robot.utils import (cut_assign_value, frange, get_error_message, is_string,
is_list_like, is_number, plural_or_not as s,
split_from_equals, type_name, Matcher)
from robot.variables import is_dict_variable, evaluate_expression
@@ -395,15 +395,18 @@ class TryRunner:
def run(self, data):
result = TryResult()
with StatusReporter(data, result, self._context, self._run):
+ failures = None
if self._run:
if data.error:
raise DataError(data.error)
runner = BodyRunner(self._context, self._run, self._templated)
try:
runner.run(data.body)
- except ExecutionFailures as failures:
+ except ExecutionFailures as error:
+ failures = error
+
for handler in data.handlers:
- run = self._error_is_expected(failures.message, handler.pattern)
+ run = failures and self._error_is_expected(failures.message, handler.pattern)
with StatusReporter(handler, ExceptResult(handler.pattern), self._context, run):
runner = BodyRunner(self._context, run, self._templated)
runner.run(handler.body)
