Exemple #1
0
 def _get_runnable_dry_run_keywords(self, args):
     keywords = Body()
     for keyword in self._get_dry_run_keywords(args):
         if contains_variable(keyword.name):
             continue
         keywords.append(keyword)
     return keywords
Exemple #2
0
 def test_no_create(self):
     error = ("'robot.model.Body' object has no attribute 'create'. "
              "Use item specific methods like 'create_keyword' instead.")
     assert_raises_with_msg(AttributeError, error,
                            getattr, Body(), 'create')
     assert_raises_with_msg(AttributeError, error.replace('.model.', '.result.'),
                            getattr, ResultBody(), 'create')
 def test_filter_with_includes_and_excludes_fails(self):
     assert_raises_with_msg(
         ValueError,
         'Items cannot be both included and excluded by type.',
         Body().filter,
         keywords=True,
         ifs=False)
Exemple #4
0
 def test_no_create(self):
     error = ("'Body' object has no attribute 'create'. "
              "Use item specific methods like 'create_keyword' instead.")
     assert_raises_with_msg(AttributeError, error,
                            getattr, Body(), 'create')
     assert_raises_with_msg(AttributeError, error.replace('Body', 'MyBody'),
                            getattr, type('MyBody', (Body,), {})(), 'create')
 def test_filter(self):
     k1, k2, k3 = Keyword(), Keyword(), Keyword()
     f1, i1, i2 = For(), If(), If()
     body = Body(items=[k1, f1, i1, i2, k2, k3])
     assert_equal(body.filter(keywords=True), [k1, k2, k3])
     assert_equal(body.filter(keywords=False), [f1, i1, i2])
     assert_equal(body.filter(ifs=True, fors=True), [f1, i1, i2])
     assert_equal(body.filter(ifs=False, fors=False), [k1, k2, k3])
     assert_equal(body.filter(), [k1, f1, i1, i2, k2, k3])
 def __init__(self, name, args=[]):
     self.name = name
     self.args = FakeArgs(args)
     self.body = Body()
     self.source = None
     self.lineno = -1
     self.return_value = None
     self.doc = Fake()
     self.timeout = Fake()
     self.return_ = Fake()
     self.tags = ()
     self.teardown = None
Exemple #7
0
 def test_filter_with_predicate(self):
     x = Keyword(name='x')
     predicate = lambda item: item.name == 'x'
     body = Body(items=[Keyword(), x, Keyword()])
     assert_equal(body.filter(predicate=predicate), [x])
     body = Body(items=[Keyword(), If(), x, For(), Keyword()])
     assert_equal(body.filter(keywords=True, predicate=predicate), [x])
Exemple #8
0
 def body(self, body):
     """Child keywords as a :class:`~.Body` object."""
     return Body(self.__class__, self, body)
Exemple #9
0
 def test_base_body_does_not_support_filtering_by_messages(self):
     error = "'robot.model.Body' object does not support filtering by 'messages'."
     assert_raises_with_msg(TypeError, error,
                            Body().filter, messages=True)
     assert_raises_with_msg(TypeError, error,
                            Body().filter, messages=False)
Exemple #10
0
 def test_filter_with_includes_and_excludes_fails(self):
     assert_raises(ValueError, Body().filter, keywords=True, ifs=False)