def _set_built_in_variables(self, settings): for name, value in [('${TEMPDIR}', abspath(tempfile.gettempdir())), ('${EXECDIR}', abspath('.')), ('${OPTIONS}', DotDict({ 'include': Tags(settings.include), 'exclude': Tags(settings.exclude), 'skip': Tags(settings.skip), 'skip_on_failure': Tags(settings.skip_on_failure) })), ('${/}', os.sep), ('${:}', os.pathsep), ('${\\n}', os.linesep), ('${SPACE}', ' '), ('${True}', True), ('${False}', False), ('${None}', None), ('${null}', None), ('${OUTPUT_DIR}', settings.output_directory), ('${OUTPUT_FILE}', settings.output or 'NONE'), ('${REPORT_FILE}', settings.report or 'NONE'), ('${LOG_FILE}', settings.log or 'NONE'), ('${DEBUG_FILE}', settings.debug_file or 'NONE'), ('${LOG_LEVEL}', settings.log_level), ('${PREV_TEST_NAME}', ''), ('${PREV_TEST_STATUS}', ''), ('${PREV_TEST_MESSAGE}', '')]: self[name] = GlobalVariableValue(value)
def __init__(self, name, error): self.name = self.longname = name self.libname = '' self.doc = self.shortdoc = '' self.error = error self.timeout = '' self.tags = Tags()
def __init__(self, name, error, libname=None): self.name = name self.libname = libname self.doc = self.shortdoc = '' self.error = unicode(error) self.timeout = '' self.tags = Tags()
def __init__(self, name, error, libname=None): self.name = name self.libname = libname self.error = unic(error) self.arguments = ArgumentSpec() self.timeout = '' self.tags = Tags()
def test_if(self): for name, expected in [('name', ''), ('args', ()), ('assign', ()), ('tags', Tags()), ('timeout', None)]: assert_equal(getattr(If(), name), expected)
def test_if_branch(self): branch = IfBranch(IfBranch.IF, '$x > 0') for name, expected in [('name', '$x > 0'), ('args', ()), ('assign', ()), ('tags', Tags()), ('timeout', None)]: assert_equal(getattr(branch, name), expected)
def test_deprecated_keyword_specific_properties(self): for_ = For(['${x}', '${y}'], 'IN', ['a', 'b', 'c', 'd']) for name, expected in [('name', '${x} | ${y} IN [ a | b | c | d ]'), ('args', ()), ('assign', ()), ('tags', Tags()), ('timeout', None)]: assert_equal(getattr(for_, name), expected)
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)
def test_deprecated_keyword_specific_properties(self): for_ = For(['${x}', '${y}'], 'IN', ['a', 'b', 'c', 'd']) tmpl = "'For.%s' is deprecated since Robot Framework 4.0." for name, expected in [('name', '${x} | ${y} IN [ a | b | c | d ]'), ('doc', ''), ('args', ()), ('assign', ()), ('tags', Tags()), ('timeout', None)]: with warnings.catch_warnings(record=True) as w: assert_equal(getattr(for_, name), expected) assert_true(str(w[0].message).startswith(tmpl % name)) assert_equal(w[0].category, UserWarning)
def test_deprecated_keyword_specific_properties(self): if_ = If('$x > 0') tmpl = "'If.%s' is deprecated since Robot Framework 4.0." for name, expected in [('name', '$x > 0'), ('doc', ''), ('args', ()), ('assign', ()), ('tags', Tags()), ('timeout', None)]: with warnings.catch_warnings(record=True) as w: assert_equal(getattr(if_, name), expected) assert_true(str(w[0].message).startswith(tmpl % name)) assert_equal(w[0].category, UserWarning)
def __init__(self, name='', args=(), doc='', shortdoc='', tags=(), source=None, lineno=-1, parent=None): self.name = name self.args = args self.doc = doc self._shortdoc = shortdoc self.tags = Tags(tags) self.source = source self.lineno = lineno self.parent = parent
def __init__(self, error, name, libname=None): """ :param robot.errors.DataError error: Occurred error. :param str name: Name of the affected keyword. :param str libname: Name of the affected library or resource. """ self.name = name self.libname = libname self.error = error self.arguments = ArgumentSpec() self.timeout = '' self.tags = Tags()
def __init__(self, name='', args=None, doc='', shortdoc='', tags=(), source=None, lineno=-1, parent=None): self.name = name self.args = args or ArgumentSpec() self.doc = doc self._shortdoc = shortdoc self.tags = Tags(tags) self.source = source self.lineno = lineno self.parent = parent # Map argument types to type documentations. self.type_docs = {arg.name: {} for arg in self.args}
def __init__(self, name='', args=(), doc='', tags=(), source=None, lineno=-1): self.name = name self.args = args self.doc = doc self.tags = Tags(tags) self.source = source self.lineno = lineno
def __init__(self, error, name, libname=None, source=None, lineno=None): """ :param robot.errors.DataError error: Occurred error. :param str name: Name of the affected keyword. :param str libname: Name of the affected library or resource. :param str source: Path to the source file. :param int lineno: Line number of the failing keyword. """ self.error = error self.name = name self.libname = libname self.source = source self.lineno = lineno self.arguments = ArgumentSpec() self.timeout = None self.tags = Tags()
def __init__(self, library, handler_name, handler_method, doc='', tags=None): self.library = library self._handler_name = handler_name self.name = self._get_name(handler_name, handler_method) self.arguments = self._parse_arguments(handler_method) self._method = self._get_initial_handler(library, handler_name, handler_method) doc, tags_from_doc = split_tags_from_doc(doc or '') tags_from_attr = self._get_tags_from_attribute(handler_method) self._doc = doc self.tags = Tags( tuple(tags_from_doc) + tuple(tags_from_attr) + tuple(tags or ()))
def test_combine(self): # This is more like an acceptance test than a unit test ... for comb_tags, tests_tags, crit_tags in [ (['t1&t2'], [['t1', 't2', 't3'], ['t1', 't3']], []), (['1&2&3'], [['1', '2', '3'], ['1', '2', '3', '4']], ['1', '2']), (['1&2', '1&3'], [['1', '2', '3'], ['1', '3'], ['1']], ['1']), (['t*'], [['t1', 'x', 'y'], ['tee', 'z'], ['t']], ['x']), (['t?&s'], [['t1', 's'], ['tt', 's', 'u'], ['tee', 's'], ['s']], []), (['t*&s', '*'], [['s', 't', 'u'], ['tee', 's'], [], ['x']], []), (['tNOTs'], [['t', 'u'], ['t', 's']], []), (['tNOTs', 't&s', 'tNOTsNOTu', 't&sNOTu'], [['t', 'u'], ['t', 's'], ['s', 't', 'u'], ['t'], ['t', 'v']], ['t']), (['nonex'], [['t1'], ['t1,t2'], []], []) ]: # 1) Create tag stats builder = TagStatisticsBuilder(Criticality(crit_tags), combined=[(t, '') for t in comb_tags]) all_tags = [] for tags in tests_tags: builder.add_test(TestCase(status='PASS', tags=tags), ) all_tags.extend(tags) # 2) Actual values names = [stat.name for stat in builder.stats] # 3) Expected values exp_crit = [] exp_noncr = [] for tag in Tags(all_tags): if tag in crit_tags: exp_crit.append(tag) else: exp_noncr.append(tag) exp_names = exp_crit + sorted(comb_tags) + exp_noncr # 4) Verify names (match counts were already verified) assert_equals(names, exp_names)
def all_tags(self): return Tags(chain.from_iterable(kw.tags for kw in self.keywords))
def __init__(self, name='', args=(), doc='', tags=()): self.name = name self.args = args self.doc = doc self.tags = Tags(tags) self.deprecated = doc.startswith('*DEPRECATED') and '*' in doc[1:]
def tags(self): return Tags()
def _get_tags_from_attribute(self, handler_method): tags = getattr(handler_method, 'robot_tags', ()) if not utils.is_list_like(tags): raise DataError("Expected tags to list like, got %s." % utils.type_name(tags)) return Tags(tags)
def __init__(self, name='', args=(), doc='', tags=()): self.name = name self.args = args self.doc = doc self.tags = Tags(tags)