def register_run_keyword(self, libname, keyword, args_to_process=None): if args_to_process is None: args_to_process = self._get_args_from_method(keyword) keyword = keyword.__name__ if libname not in self._libs: self._libs[libname] = NormalizedDict(ignore=['_']) self._libs[libname][keyword] = int(args_to_process)
def __init__(self, combined_stats): #: Dictionary, where key is the name of the tag as a string and value #: is an instance of :class:`~robot.model.stats.TagStat`. self.tags = NormalizedDict(ignore=['_']) #: Dictionary, where key is the name of the created tag as a string # and value is an instance of :class:`~robot.model.stats.TagStat`. self.combined = combined_stats
class EmptyFinder(object): identifiers = '$@&' find = NormalizedDict({ '${EMPTY}': '', '@{EMPTY}': (), '&{EMPTY}': {} }, ignore='_').__getitem__
class ForLoop(_WithSteps): """The parsed representation of a for-loop. :param list declaration: The literal cell values that declare the loop (excluding ":FOR"). :param str comment: A comment, default None. :ivar str flavor: The value of the 'IN' item, uppercased. Typically 'IN', 'IN RANGE', 'IN ZIP', or 'IN ENUMERATE'. :ivar list vars: Variables set per-iteration by this loop. :ivar list items: Loop values that come after the 'IN' item. :ivar str comment: A comment, or None. :ivar list steps: A list of steps in the loop. """ flavors = {'IN', 'IN RANGE', 'IN ZIP', 'IN ENUMERATE'} normalized_flavors = NormalizedDict((f, f) for f in flavors) def __init__(self, parent, declaration, comment=None): self.parent = parent self.flavor, index = self._get_flavor_and_index(declaration) self.vars = declaration[:index] self.items = declaration[index + 1:] self.comment = Comment(comment) self.steps = [] def _get_flavor_and_index(self, declaration): for index, item in enumerate(declaration): if item in self.flavors: return item, index if item in self.normalized_flavors: correct = self.normalized_flavors[item] self._report_deprecated_flavor_syntax(item, correct) return correct, index if normalize(item).startswith('in'): return item.upper(), index return 'IN', len(declaration) def _report_deprecated_flavor_syntax(self, deprecated, correct): self.parent.report_invalid_syntax( "Using '%s' as a FOR loop separator is deprecated. " "Use '%s' instead." % (deprecated, correct), level='WARN') def is_comment(self): return False def is_for_loop(self): return True def as_list(self, indent=False, include_comment=True): comments = self.comment.as_list() if include_comment else [] return ['FOR'] + self.vars + [self.flavor] + self.items + comments def __iter__(self): return iter(self.steps) def is_set(self): return True
def __init__(self, critical_stats, non_critical_stats, combined_stats): #: Dictionary, where key is the name of the tag as a string and value #: is an instance of :class:`~robot.model.stats.TagStat`. self.tags = NormalizedDict(ignore='_') #: List of :class:`~robot.model.stats.CriticalTagStat` objects. self.critical = critical_stats #: List of :class:`~robot.model.stats.CriticalTagStat` objects. self.non_critical = non_critical_stats #: List of :class:`~robot.model.stats.CombinedTagStat` objects. self.combined = combined_stats
def register_run_keyword(self, libname, keyword, args_to_process=None, deprecation_warning=True): if deprecation_warning: warnings.warn(self._deprecation_warning(), UserWarning) if args_to_process is None: args_to_process = self._get_args_from_method(keyword) keyword = keyword.__name__ if libname not in self._libs: self._libs[libname] = NormalizedDict(ignore=['_']) self._libs[libname][keyword] = int(args_to_process)
def start_suite(self, suite): self._output.library_listeners.new_suite_scope() result = TestSuite(source=suite.source, name=suite.name, doc=suite.doc, metadata=suite.metadata, starttime=get_timestamp(), rpa=self._settings.rpa) if not self.result: result.set_criticality(self._settings.critical_tags, self._settings.non_critical_tags) self.result = Result(root_suite=result, rpa=self._settings.rpa) self.result.configure(status_rc=self._settings.status_rc, stat_config=self._settings.statistics_config) else: self._suite.suites.append(result) self._suite = result self._suite_status = SuiteStatus(self._suite_status, self._settings.exit_on_failure, self._settings.exit_on_error, self._settings.skip_teardown_on_exit) ns = Namespace(self._variables, result, suite.resource) ns.start_suite() ns.variables.set_from_variable_table(suite.resource.variables) EXECUTION_CONTEXTS.start_suite(result, ns, self._output, self._settings.dry_run) self._context.set_suite_variables(result) if not self._suite_status.failures: ns.handle_imports() ns.variables.resolve_delayed() result.doc = self._resolve_setting(result.doc) result.metadata = [(self._resolve_setting(n), self._resolve_setting(v)) for n, v in result.metadata.items()] self._context.set_suite_variables(result) self._output.start_suite( ModelCombiner(suite, result, tests=suite.tests, suites=suite.suites, test_count=suite.test_count)) self._output.register_error_listener(self._suite_status.error_occurred) self._run_setup(suite.keywords.setup, self._suite_status) self._executed_tests = NormalizedDict(ignore='_')
def _escape_and_encode_targets(self, targets): return NormalizedDict( (html_escape(key), self._encode_uri_component(value)) for key, value in targets.items())
def start_suite(self): if not self._scopes: self._suite = NormalizedDict(ignore='_') else: self._suite = self._scopes[-1].copy() self._scopes.append(self._suite)
def _normalize(self, tags): normalized = NormalizedDict(((unic(t), 1) for t in tags), ignore='_') for removed in '', 'NONE': if removed in normalized: normalized.pop(removed) return tuple(normalized)
def _get_critical_and_non_critical_matcher(self): crits = [stat for stat in self.critical + self.non_critical if isinstance(stat.pattern, SingleTagPattern)] return NormalizedDict([(unicode(stat.pattern), None) for stat in crits], ignore='_')
def __init__(self, parent=None, source=None): self.parent = parent self.source = abspath(source) if source else None self.children = [] self._tables = NormalizedDict(self._get_tables())
def as_dict(self, decoration=True): if decoration: variables = (self._decorate(name, self[name]) for name in self) else: variables = self.data return NormalizedDict(variables, ignore='_')
def __init__(self, variables): self.data = NormalizedDict(ignore='_') self._variables = variables
def __init__(self, source): self._source = source self._normal = NormalizedDict(ignore='_') self._embedded = []