Exemplo n.º 1
0
 def _verify_lib(self, lib, libname, keywords):
     assert_equals(libname, lib.name)
     for name, _ in keywords:
         handler = lib.handlers[name]
         exp = "%s.%s" % (libname, name)
         assert_equals(utils.normalize(handler.longname),
                       utils.normalize(exp))
Exemplo n.º 2
0
 def _get_deprecated_setter(self, name):
     normalized = normalize(name)
     for setting in list(self._setters) + list(self._aliases):
         if normalize(setting) == normalized:
             self._report_deprecated_setting(name, setting)
             return self._get_setter(setting)
     return None
Exemplo n.º 3
0
 def _verify_lib(self, lib, libname, keywords):
     assert_equals(libname, lib.name)
     for name, _ in keywords:
         handler = lib.get_handler(name)
         exp = "%s.%s" % (libname, name)
         assert_equals(utils.normalize(handler.longname),
                       utils.normalize(exp))
Exemplo n.º 4
0
    def check_suite_contains_tests(self, suite, *expected_names, **statuses):
        actual_tests = [test for test in self.get_tests_from_suite(suite)]
        tests_msg = """
Expected tests : %s
Actual tests   : %s""" % (str(list(expected_names)), str(actual_tests))
        expected_names = [utils.normalize(name) for name in expected_names]
        statuses = dict((utils.normalize(k), v) for k, v in statuses.items())
        if len(actual_tests) != len(expected_names):
            raise AssertionError("Wrong number of tests." + tests_msg)
        for test in actual_tests:
            norm_name = utils.normalize(test.name)
            if utils.MultiMatcher(expected_names).match(test.name):
                print("Verifying test '%s'" % test.name)
                status = statuses.get(norm_name)
                if status and ':' in status:
                    status, message = status.split(':', 1)
                else:
                    message = None
                self.check_test_status(test, status, message)
                expected_names.remove(norm_name)
            else:
                raise AssertionError(
                    "Test '%s' was not expected to be run.%s" %
                    (test.name, tests_msg))
        assert not expected_names
Exemplo n.º 5
0
 def _get_deprecated_setter(self, name):
     normalized = normalize(name)
     for setting in list(self._setters) + list(self._aliases):
         if normalize(setting) == normalized:
             self._report_deprecated_setting(name, setting)
             return self._get_setter(setting)
     return None
Exemplo n.º 6
0
    def check_suite_contains_tests(self, suite, *expected_names, **statuses):
        actual_tests = [test for test in self.get_tests_from_suite(suite)]
        tests_msg = """
Expected tests : %s
Actual tests   : %s""" % (
            str(list(expected_names)),
            str(actual_tests),
        )
        expected_names = [utils.normalize(name) for name in expected_names]
        statuses = dict((utils.normalize(k), v) for k, v in statuses.items())
        if len(actual_tests) != len(expected_names):
            raise AssertionError("Wrong number of tests." + tests_msg)
        for test in actual_tests:
            norm_name = utils.normalize(test.name)
            if utils.MultiMatcher(expected_names).match(test.name):
                print "Verifying test '%s'" % test.name
                status = statuses.get(norm_name)
                if status and ":" in status:
                    status, message = status.split(":", 1)
                else:
                    message = None
                self.check_test_status(test, status, message)
                expected_names.remove(norm_name)
            else:
                raise AssertionError("Test '%s' was not expected to be run.%s" % (test.name, tests_msg))
        assert not expected_names
Exemplo n.º 7
0
 def test_normalize_with_ignore(self):
     assert_equals(normalize('Foo_ bar', ignore=['_']), 'foobar')
     assert_equals(normalize('Foo_ bar', ignore=['_', 'f', 'o']), 'bar')
     assert_equals(normalize('Foo_ bar', ignore=['_', 'F', 'o']), 'bar')
     assert_equals(normalize('Foo_ bar', ignore=['_', 'f', 'o'],
                             caseless=False), 'Fbar')
     assert_equals(normalize('Foo_\n bar\n', ignore=['\n'],
                             spaceless=False), 'foo_ bar')
Exemplo n.º 8
0
 def test_normalize_with_ignore(self):
     assert_equals(normalize('Foo_ bar', ignore=['_']), 'foobar')
     assert_equals(normalize('Foo_ bar', ignore=['_', 'f', 'o']), 'bar')
     assert_equals(normalize('Foo_ bar', ignore=['_', 'F', 'o']), 'bar')
     assert_equals(normalize('Foo_ bar', ignore=['_', 'f', 'o'],
                             caseless=False), 'Fbar')
     assert_equals(normalize('Foo_\n bar\n', ignore=['\n'],
                             spaceless=False), 'foo_ bar')
Exemplo n.º 9
0
 def _resolve_deprecated_table(self, used_name):
     normalized = normalize(used_name)
     for name in (self._setting_table_names + self._variable_table_names +
                  self._testcase_table_names + self._keyword_table_names +
                  self._comment_table_names):
         if normalize(name) == normalized:
             self._report_deprecated_table(used_name, name)
             return name
     return None
Exemplo n.º 10
0
 def _resolve_deprecated_table(self, used_name):
     normalized = normalize(used_name)
     for name in (self._setting_table_names + self._variable_table_names +
                  self._testcase_table_names + self._keyword_table_names +
                  self._comment_table_names):
         if normalize(name) == normalized:
             self._report_deprecated_table(used_name, name)
             return name
     return None
Exemplo n.º 11
0
 def _add_to_dict(self, s_or_t, column_name):
     name = s_or_t.longname.replace('_', ' ')
     keys = self.suites_and_tests.keys()
     found = False
     for key in keys:
         if utils.normalize(name, caseless=True, spaceless=True) == \
             utils.normalize(key, caseless=True, spaceless=True):
             found = True
             foundkey = key
     if not found:
         self.suites_and_tests[name] = [(column_name, s_or_t)]
     else:
         self.suites_and_tests[foundkey].append((column_name, s_or_t))
Exemplo n.º 12
0
 def _convert(self, value, explicit_type=True):
     try:
         # This is compatible with the enum module in Python 3.4, its
         # enum34 backport, and the older enum module. `self._enum[value]`
         # wouldn't work with the old enum module.
         return getattr(self._enum, value)
     except AttributeError:
         members = self._get_members(self._enum)
         normalized_value = normalize(value, ignore='_')
         for member in members:
             if normalize(member, ignore='_') == normalized_value:
                 return getattr(self._enum, member)
         raise ValueError("%s does not have member '%s'. Available: %s" %
                          (self.type_name, value, seq2str(members)))
Exemplo n.º 13
0
 def check_attribute(self, name, expected):
     try:
         actual = getattr(self, utils.normalize(name))
     except AttributeError:
         raise AssertionError("Attribute '%s' not set" % name)
     if not utils.eq(actual, expected):
         raise AssertionError("Attribute '%s' was '%s', expected '%s'" % (name, actual, expected))
Exemplo n.º 14
0
 def normalizer(value):
     """Normalize `value` based on normalizing options from metaclass.
     """
     if isinstance(value, UserString):
         value = value.data
     return normalize(value, ignore=cls.ignore,
       caseless=cls.caseless, spaceless=cls.spaceless)
 def test_normalize_with_defaults(self):
     for inp, exp in [('', ''), ('            ', ''), (' \n\t\r', ''),
                      ('foo', 'foo'), ('BAR', 'bar'), (' f o o ', 'foo'),
                      ('_BAR', '_bar'), ('Fo OBar\r\n', 'foobar'),
                      ('foo\tbar', 'foobar'),
                      ('\n \n \n \n F o O \t\tBaR \r \r \r   ', 'foobar')]:
         assert_equals(normalize(inp), exp)
Exemplo n.º 16
0
 def _get_scope(self, libcode):
     try:
         scope = libcode.ROBOT_LIBRARY_SCOPE
         scope = utils.normalize(scope, ignore=['_']).upper()
     except (AttributeError, TypeError):
         scope = 'TESTCASE'
     return scope if scope in ['GLOBAL', 'TESTSUITE'] else 'TESTCASE'
Exemplo n.º 17
0
 def _get_scope(self, libcode):
     try:
         scope = libcode.ROBOT_LIBRARY_SCOPE
         scope = utils.normalize(scope, ignore=['_']).upper()
     except (AttributeError, TypeError):
         scope = 'TESTCASE'
     return scope if scope in ['GLOBAL','TESTSUITE'] else 'TESTCASE'
    def check_suite_contains_tests(self, suite, *expected_names):
        actual_tests = [test for test in self.get_tests_from_suite(suite)]
        tests_msg  = """
Expected tests : %s
Actual tests   : %s"""  % (str(list(expected_names)), str(actual_tests))
        expected_names = [utils.normalize(name) for name in expected_names]
        if len(actual_tests) != len(expected_names):
            raise AssertionError("Wrong number of tests." + tests_msg)
        for test in actual_tests:
            if any(utils.matches(test.name, name) for name in expected_names):
                print "Verifying test '%s'" % test.name
                self.check_test_status(test)
                expected_names.remove(utils.normalize(test.name))
            else:
                raise AssertionError("Test '%s' was not expected to be run.%s"
                                     % (test.name, tests_msg))
        assert not expected_names
Exemplo n.º 19
0
 def normalizer(value):
     """Normalize `value` based on normalizing options
        given to :func:`normstringclass`.
     """
     if isinstance(value, UserString):
         value = value.data
     return normalize(value, ignore=normalizer.ignore,
       caseless=normalizer.caseless, spaceless=normalizer.spaceless)
Exemplo n.º 20
0
 def find(self, name):
     if name[0] != '$':
         raise ValueError
     number = normalize(name)[2:-1]
     try:
         return self._get_int(number)
     except ValueError:
         return float(number)
 def find(self, name):
     number = normalize(name)[2:-1]
     for converter in self._get_int, float:
         try:
             return converter(number)
         except ValueError:
             pass
     return NOT_FOUND
Exemplo n.º 22
0
    def check_suite_contains_tests(self, suite, *expected_names):
        actual_tests = [test for test in self.get_tests_from_suite(suite)]
        tests_msg  = """
Expected tests : %s
Actual tests   : %s"""  % (str(list(expected_names)), str(actual_tests))
        expected_names = [utils.normalize(name) for name in expected_names]
        if len(actual_tests) != len(expected_names):
            raise AssertionError("Wrong number of tests." + tests_msg)
        for test in actual_tests:
            if any(utils.matches(test.name, name) for name in expected_names):
                print "Verifying test '%s'" % test.name
                self.check_test_status(test)
                expected_names.remove(utils.normalize(test.name))
            else:
                raise AssertionError("Test '%s' was not expected to be run.%s"
                                     % (test.name, tests_msg))
        assert not expected_names
Exemplo n.º 23
0
 def find(self, name):
     if name[0] != '$':
         raise ValueError
     number = normalize(name)[2:-1]
     try:
         return self._get_int(number)
     except ValueError:
         return float(number)
Exemplo n.º 24
0
 def check_attribute(self, name, expected):
     try:
         actual = getattr(self, utils.normalize(name))
     except AttributeError:
         raise AssertionError("Attribute '%s' not set" % name)
     if not utils.eq(actual, expected):
         raise AssertionError("Attribute '%s' was '%s', expected '%s'"
                              % (name, actual, expected))
Exemplo n.º 25
0
 def _get_attr(self, fields, name, upper=False):
     name = 'ROBOT_LIBRARY_' + name
     for field in fields:
         if field.getSimpleName().toString() == name:
             value = field.getConstantValue()
             if upper:
                 value = normalize(value, ignore='_').upper()
             return value
     return ''
Exemplo n.º 26
0
 def _get_attr(self, fields, name, upper=False):
     name = 'ROBOT_LIBRARY_' + name
     for field in fields:
         if field.getSimpleName().toString() == name:
             value = field.getConstantValue()
             if upper:
                 value = normalize(value, ignore='_').upper()
             return value
     return ''
Exemplo n.º 27
0
 def recommend_similar_keywords(self, name, message):
     """Return keyword names similar to `name`."""
     candidates = self._get_candidates('.' in name)
     finder = RecommendationFinder(
         lambda name: normalize(candidates.get(name, name), ignore='_'))
     return finder.find_and_format(name,
                                   candidates,
                                   message,
                                   check_missing_argument_separator=True)
Exemplo n.º 28
0
 def normalizer(value):
     """Normalize `value` based on normalizing options from metaclass.
     """
     if isinstance(value, UserString):
         value = value.data
     return normalize(value,
                      ignore=cls.ignore,
                      caseless=cls.caseless,
                      spaceless=cls.spaceless)
Exemplo n.º 29
0
 def _get_attr(self, doc, name, default='', upper=False):
     name = 'ROBOT_LIBRARY_' + name
     for field in doc.fields():
         if field.name() == name and field.isPublic():
             value = field.constantValue()
             if upper:
                 value = utils.normalize(value, ignore='_').upper()
             return value
     return default
Exemplo n.º 30
0
 def _get_attr(self, doc, name, default='', upper=False):
     name = 'ROBOT_LIBRARY_' + name
     for field in doc.fields():
         if field.name() == name and field.isPublic():
             value = field.constantValue()
             if upper:
                 value = utils.normalize(value, ignore='_').upper()
             return value
     return default
Exemplo n.º 31
0
 def _run_tests(self, context, errors):
     executed_tests = []
     for test in self.tests:
         normname = utils.normalize(test.name)
         if normname in executed_tests:
             LOGGER.warn("Multiple test cases with name '%s' executed in "
                         "test suite '%s'"% (test.name, self.longname))
         executed_tests.append(normname)
         test.run(context, errors)
         context.set_prev_test_variables(test)
Exemplo n.º 32
0
    def normalizer(value):
        """Normalize `value` based on normalizing options
           given to :func:`normboolclass`.

        - Any non-string values are just passed through.
        """
        if not isinstance(value, string_types):
            return value
        return normalize(value, ignore=normalizer.ignore,
          caseless=normalizer.caseless, spaceless=normalizer.spaceless)
Exemplo n.º 33
0
 def normalizer(value):
     """Normalize `value` based on normalizing options
        given to :func:`normstringclass`.
     """
     if isinstance(value, UserString):
         value = value.data
     return normalize(value,
                      ignore=normalizer.ignore,
                      caseless=normalizer.caseless,
                      spaceless=normalizer.spaceless)
Exemplo n.º 34
0
 def _run_tests(self, context, errors):
     executed_tests = []
     for test in self.tests:
         normname = utils.normalize(test.name)
         if normname in executed_tests:
             LOGGER.warn("Multiple test cases with name '%s' executed in "
                         "test suite '%s'" % (test.name, self.longname))
         executed_tests.append(normname)
         test.run(context, errors)
         context.set_prev_test_variables(test)
Exemplo n.º 35
0
 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)
Exemplo n.º 36
0
 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)
Exemplo n.º 37
0
 def _set_execution_mode(self, data):
     rpa = normalize(data.testcase_table.header[0]) in ('task', 'tasks')
     if self.rpa is None:
         self.rpa = rpa
     elif self.rpa is not rpa:
         this, that = ('tasks', 'tests') if rpa else ('tests', 'tasks')
         raise DataError("Conflicting execution modes. File '%s' has %s "
                         "but files parsed earlier have %s. Fix headers "
                         "or use '--rpa' or '--norpa' options to set the "
                         "execution mode explicitly." %
                         (data.source, this, that))
Exemplo n.º 38
0
 def _set_execution_mode(self, data):
     rpa = normalize(data.testcase_table.header[0]) in ('task', 'tasks')
     if self.rpa is None:
         self.rpa = rpa
     elif self.rpa is not rpa:
         this, that = ('tasks', 'tests') if rpa else ('tests', 'tasks')
         raise DataError("Conflicting execution modes. File '%s' has %s "
                         "but files parsed earlier have %s. Fix headers "
                         "or use '--rpa' or '--norpa' options to set the "
                         "execution mode explicitly."
                         % (data.source, this, that))
Exemplo n.º 39
0
    def convert_path(self, path_in, dir_out, format_in, format_out, root=None):
        root = root if root is not None else Path.cwd()

        # Override default docstring format
        if path_in in self.config.get("override_docstring", {}):
            self.logger.debug(f"Overriding docstring format for '{path_in}'")
            format_in = self.config["override_docstring"][path_in]

        # Override default output format
        if path_in in self.config.get("override_format", {}):
            self.logger.debug(f"Overriding output format for '{path_in}'")
            format_out = self.config["override_format"][path_in]

        converter = CONVERTERS[format_out]

        path_rel = path_in.with_suffix(converter.EXTENSION).relative_to(root)
        if self.config.get("collapse", False):
            path_out = Path(dir_out) / Path("_".join(
                part.lower() for part in path_rel.parts))
        else:
            path_out = Path(dir_out) / path_rel

        path_out.parent.mkdir(parents=True, exist_ok=True)

        self.logger.debug("Converting '%s' to '%s'", path_in, path_out)
        libdoc = LibraryDocumentation(str(path_in),
                                      doc_format=format_in.upper())

        # Override name with user-given value
        if self.config.get("title"):
            libdoc.name = self.config["title"]
        # Create module path for library, e.g. RPA.Excel.Files
        else:
            namespace = []
            if self.config.get("namespace"):
                namespace.append(self.config["namespace"])
            if path_rel.parent != Path("."):
                namespace.append(str(path_rel.parent).replace(os.sep, "."))
            if namespace:
                libdoc.name = "{namespace}.{name}".format(
                    namespace=".".join(namespace),
                    name=libdoc.name,
                )

        # Convert library scope to RPA format
        if self.config.get("rpa", False):
            scope = normalize(unic(libdoc.scope), ignore="_")
            libdoc.scope = {
                "testcase": "Task",
                "testsuite": "Suite",
                "global": "Global",
            }.get(scope, "")

        converter().convert(libdoc, path_out)
Exemplo n.º 40
0
 def test_normalize_with_defaults(self):
     for inp, exp in [('', ''),
                      ('            ', ''),
                      (' \n\t\r', ''),
                      ('foo', 'foo'),
                      ('BAR', 'bar'),
                      (' f o o ', 'foo'),
                      ('_BAR', '_bar'),
                      ('Fo OBar\r\n', 'foobar'),
                      ('foo\tbar', 'foobar'),
                      ('\n \n \n \n F o O \t\tBaR \r \r \r   ', 'foobar')]:
         assert_equals(normalize(inp), exp)
Exemplo n.º 41
0
    def normalizer(value):
        """Normalize `value` based on normalizing options
           given to :func:`normboolclass`.

        - Any non-string values are just passed through.
        """
        if not isinstance(value, string_types):
            return value
        return normalize(value,
                         ignore=normalizer.ignore,
                         caseless=normalizer.caseless,
                         spaceless=normalizer.spaceless)
Exemplo n.º 42
0
 def repeat_keyword(self,times,name,*args):
     times = utils.normalize(str(times))
     if times.endswith('times'):
         times = times[:-5]
     elif times.endswith('x'):
         times = times[:-1]
     times = self._convert_to_integer(times)
     if times <=0:
         self.log("Keyword '%s repeat zero times" %name)
     for i in xrange(times):
         self.log("Repeating keyword,round %d/%d" %(i+1,times))
         self.run_keyword(name,*args)
Exemplo n.º 43
0
 def test_normalize_with_defaults(self):
     for inp, exp in [
         ("", ""),
         ("            ", ""),
         (" \n\t\r", ""),
         ("foo", "foo"),
         (" f o o ", "foo"),
         ("_BAR", "_bar"),
         ("Fo OBar\r\n", "foobar"),
         ("foo\tbar", "foobar"),
         ("\n \n \n \n F o O \t\tBaR \r \r \r   ", "foobar"),
     ]:
         assert_equals(exp, normalize(inp))
Exemplo n.º 44
0
    def _get_base(self,item,base):
        if not isinstance(item,basestring):
            return item,base
        item = utils.normalize(item)
        if item.startswith(('-','+')):
            sign = item[0]
            item =item[1:]
        else:
            sign = ''
        base = {'0b':2,'0o':8,'0x': 16}

        if base or not item.startswith(tuple(bases)):
            return sign+item,base
        return sign+item[2:],bases[item[:2]]
    def convert_to_bool(self, value, *true_false, **options):
        if true_false:
            lists = NormalizedDict({'true': [], 'false': []})
            # choose the first list to fill with items
            #  based on given TRUE or FALSE specifier:
            try:
                t_or_f_list = lists[true_false[0]]
            except KeyError:
                raise ValueError("Expected TRUE or FALSE, not: %s" %
                                 repr(true_false[0]))
            for item in true_false[1:]:
                if item in lists:  #==> is new TRUE or FALSE specifier
                    #==> switch to corresponding list
                    t_or_f_list = lists[item]
                    if t_or_f_list:
                        raise ValueError("Multiple %s lists specfied." %
                                         normalize(item).upper())
                else:
                    t_or_f_list.append(item)
            for key, items in lists.items():
                if not items:
                    raise ValueError("No %s list specified." % key.upper())
            if RobotBool(options.get('normalized', True)):
                boolcls = normboolclass(**lists)
            else:
                boolcls = boolclass(**lists)
        else:
            boolcls = options.get('boolclass') or options.get('booltype')
            if not boolcls:  # fallback to robot's default bool conversion
                return BUILTIN.convert_to_boolean(value)

            if isstring(boolcls):
                try:  # is a registered bool class name?
                    boolcls = BOOL_CLASSES[boolcls]
                except KeyError:
                    if '.' not in boolcls:
                        raise ValueError(
                            "No such bool class registered: '%s'" % boolcls)
                    modname, clsname = boolcls.rsplit('.', 1)
                    try:  # is an importable 'module.class' string?
                        boolcls = getattr(__import__(modname), clsname)
                    except (ImportError, AttributeError):
                        raise ValueError("Can't import bool class: '%s'" %
                                         boolcls)
            elif not isboolclass(boolcls):
                raise TypeError("No bool class: %s" % repr(boolcls))

        BUILTIN._log_types(value)
        return boolcls(value)
    def convert_to_bool(self, value, *true_false, **options):
        if true_false:
            lists = NormalizedDict({'true': [], 'false': []})
            # choose the first list to fill with items
            #  based on given TRUE or FALSE specifier:
            try:
                t_or_f_list = lists[true_false[0]]
            except KeyError:
                raise ValueError("Expected TRUE or FALSE, not: %s"
                                 % repr(true_false[0]))
            for item in true_false[1:]:
                if item in lists: #==> is new TRUE or FALSE specifier
                    #==> switch to corresponding list
                    t_or_f_list = lists[item]
                    if t_or_f_list:
                        raise ValueError("Multiple %s lists specfied."
                                         % normalize(item).upper())
                else:
                    t_or_f_list.append(item)
            for key, items in lists.items():
                if not items:
                    raise ValueError("No %s list specified." % key.upper())
            if RobotBool(options.get('normalized', True)):
                boolcls = normboolclass(**lists)
            else:
                boolcls = boolclass(**lists)
        else:
            boolcls = options.get('boolclass') or options.get('booltype')
            if not boolcls: # fallback to robot's default bool conversion
                return BUILTIN.convert_to_boolean(value)

            if isstring(boolcls):
                try: # is a registered bool class name?
                    boolcls = BOOL_CLASSES[boolcls]
                except KeyError:
                    if '.' not in boolcls:
                        raise ValueError(
                          "No such bool class registered: '%s'" % boolcls)
                    modname, clsname = boolcls.rsplit('.', 1)
                    try: # is an importable 'module.class' string?
                        boolcls = getattr(__import__(modname), clsname)
                    except (ImportError, AttributeError):
                        raise ValueError(
                          "Can't import bool class: '%s'" % boolcls)
            elif not isboolclass(boolcls):
                raise TypeError("No bool class: %s" % repr(boolcls))

        BUILTIN._log_types(value)
        return boolcls(value)
Exemplo n.º 47
0
 def __init__(self, name):
     #: Human readable identifier of the object these statistics
     #: belong to. Either `All Tests` or `Critical Tests` for
     #: :class:`~robot.model.totalstatistics.TotalStatistics`,
     #: long name of the suite for
     #: :class:`~robot.model.suitestatistics.SuiteStatistics`
     #: or name of the tag for
     #: :class:`~robot.model.tagstatistics.TagStatistics`
     self.name = name
     #: Number of passed tests.
     self.passed = 0
     #: Number of failed tests.
     self.failed = 0
     #: Number of milliseconds it took to execute.
     self.elapsed = 0
     self._norm_name = normalize(name, ignore='_')
Exemplo n.º 48
0
 def __init__(self, name):
     #: Human readable identifier of the object these statistics
     #: belong to. Either `All Tests` or `Critical Tests` for
     #: :class:`~robot.model.totalstatistics.TotalStatistics`,
     #: long name of the suite for
     #: :class:`~robot.model.suitestatistics.SuiteStatistics`
     #: or name of the tag for
     #: :class:`~robot.model.tagstatistics.TagStatistics`
     self.name = name
     #: Number of passed tests.
     self.passed = 0
     #: Number of failed tests.
     self.failed = 0
     #: Number of milliseconds it took to execute.
     self.elapsed = 0
     self._norm_name = normalize(name, ignore='_')
Exemplo n.º 49
0
 def _get_attr(self, object, attr, default="", upper=False):
     value = unic(getattr(object, attr, default))
     if upper:
         value = normalize(value, ignore="_").upper()
     return value
Exemplo n.º 50
0
 def _get_attr(self, object, attr, default='', upper=False):
     value = unic(getattr(object, attr, default))
     if upper:
         value = normalize(value, ignore='_').upper()
     return value
 def set_attribute(self, name, value):
     setattr(self, utils.normalize(name), utils.normalize(value))
Exemplo n.º 52
0
 def recommend_similar_keywords(self, name):
     """Return keyword names similar to `name`."""
     candidates = self._get_candidates('.' in name)
     finder = RecommendationFinder(
         lambda name: normalize(candidates.get(name, name), ignore='_'))
     return finder.find(name, candidates)
Exemplo n.º 53
0
 def find(self, name):
     number = normalize(name)[2:-1]
     try:
         return self._get_int(number)
     except ValueError:
         return float(number)
Exemplo n.º 54
0
 def delete(self, alias):
     del(self._apps[normalize(alias)])
     del(self._old_apps[normalize(alias)])
     self._store()
def _get_scope(libcode):
    if inspect.ismodule(libcode):
        return 'global'
    scope = getattr(libcode, 'ROBOT_LIBRARY_SCOPE', '')
    return normalize(unic(scope), ignore='_')
 def get_attribute(self, name):
     return getattr(self, utils.normalize(name))
 def check_attribute_not_set(self, name):
     if hasattr(self, utils.normalize(name)):
         raise AssertionError("Attribute '%s' should not be set" % name)
 def _verify(self, string, expected, **config):
     assert_equal(normalize(string, **config), expected)
Exemplo n.º 59
0
 def _verify_lib(self, lib, libname, keywords):
     assert_equal(libname, lib.name)
     for name, _ in keywords:
         handler = lib.handlers[name]
         exp = "%s.%s" % (libname, name)
         assert_equal(normalize(handler.longname), normalize(exp))
Exemplo n.º 60
0
 def normalize(self, setting):
     result = utils.normalize(setting)
     return result[0:-1] if result and result[-1]==':' else result