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
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)
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
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])
def body(self, body): """Child keywords as a :class:`~.Body` object.""" return Body(self.__class__, self, body)
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)
def test_filter_with_includes_and_excludes_fails(self): assert_raises(ValueError, Body().filter, keywords=True, ifs=False)