Exemplo n.º 1
0
 def _run_if_branch(self, data, recursive_dry_run=False, branch_run=False):
     result = IfResult(data.condition,
                       lineno=data.lineno,
                       source=data.source,
                       type=data.type)
     error = None
     with StatusReporter(self._context, result, self._run):
         if data.error and self._run:
             raise DataError(data.error)
         run = self._should_run_branch(data.condition, branch_run,
                                       recursive_dry_run)
         runner = BodyRunner(self._context,
                             run=run,
                             templated=self._templated)
         try:
             if not recursive_dry_run:
                 runner.run(data.body)
         except ExecutionStatus as err:
             error = err
         if run:
             branch_run = True
         else:
             result.branch_status = result.NOT_RUN
         if data.orelse:
             self._run_if_branch(data.orelse, recursive_dry_run, branch_run)
         if error:
             raise error
Exemplo n.º 2
0
 def test_status_propertys_with_control_structures(self):
     for obj in (Break(),
                 Continue(), Return(), For(), For().body.create_iteration(),
                 If(), If().body.create_branch(), Try(),
                 Try().body.create_branch(), While(),
                 While().body.create_iteration()):
         self._verify_status_propertys(obj)
Exemplo n.º 3
0
 def _run_if_branch(self, data, recursive_dry_run=False, branch_run=False):
     result = IfResult(data.condition, lineno=data.lineno, source=data.source,
                       type=data.type)
     with StatusReporter(self._context, result) as reporter:
         if data.error:
             raise DataError(data.error)
         if self._should_run_branch(data.condition, branch_run, recursive_dry_run):
             runner = StepRunner(self._context, self._templated)
             runner.run_steps(data.body)
             branch_run = True
         else:
             result.branch_status = 'NOT_RUN'
         if data.orelse:
             self._run_if_branch(data.orelse, recursive_dry_run, branch_run)
Exemplo n.º 4
0
 def test_create_supported(self):
     for parent in If(), Try():
         branches = parent.body
         for creator in (branches.create_branch, branches.create_message,
                         branches.create_keyword):
             item = creator()
             assert_equal(item.parent, parent)
Exemplo n.º 5
0
 def test_if(self):
     for name, expected in [('name', ''),
                            ('args', ()),
                            ('assign', ()),
                            ('tags', Tags()),
                            ('timeout', None)]:
         assert_equal(getattr(If(), name), expected)
Exemplo n.º 6
0
 def test_create_not_supported(self):
     msg = "'robot.result.Branches' object does not support '{}'."
     for parent in If(), Try():
         branches = parent.body
         for creator in (branches.create_for, branches.create_if,
                         branches.create_try, branches.create_return):
             assert_raises_with_msg(TypeError, msg.format(creator.__name__),
                                    creator)
Exemplo n.º 7
0
 def test_if(self):
     if_ = If('$x > 0')
     for name, expected in [('name', '$x > 0'),
                            ('args', ()),
                            ('assign', ()),
                            ('tags', Tags()),
                            ('timeout', None)]:
         assert_equal(getattr(if_, name), expected)
Exemplo n.º 8
0
 def test_if(self):
     self._verify(If())
     self._verify(If().body.create_branch())
Exemplo n.º 9
0
 def test_status_propertys_with_if(self):
     self._verify_status_propertys(If())
Exemplo n.º 10
0
 def test_if(self):
     self._verify(If())