Exemplo n.º 1
0
def to_bool(item):
    if isinstance(item, basestring):
        if utils.eq(item, 'True'):
            return True
        if utils.eq(item, 'False'):
            return False
    return bool(item)
Exemplo n.º 2
0
 def convert_to_boolean(self,item):
     self._log_types(item)
     if isinstance(item,basestring):
         if utils.eq(item,'True'):
             return True
         if utils.eq(item,'False'):
             return False
     return bool(item)
Exemplo n.º 3
0
 def _process_value(self, name, value, log):
     if name == 'LogLevel':
         return self._process_log_level(value)
     if value == self._get_default_value(name):
         return value
     if name in ['Name', 'Doc', 'LogTitle', 'ReportTitle']:
         if name == 'Doc': value = self._escape(value)
         return value.replace('_', ' ')
     if name in ['Metadata', 'TagDoc']:
         if name == 'Metadata': value = [self._escape(v) for v in value]
         return [self._process_metadata_or_tagdoc(v) for v in value]
     if name in ['Include', 'Exclude']:
         return [v.replace('AND', '&').replace('_', ' ') for v in value]
     if name in self._output_opts and utils.eq(value, 'NONE'):
         return 'NONE'
     if name == 'OutputDir':
         return utils.abspath(value)
     if name in ['SuiteStatLevel', 'MonitorWidth']:
         return self._convert_to_positive_integer_or_default(name, value)
     if name in ['Listeners', 'VariableFiles']:
         return [self._split_args_from_name_or_path(item) for item in value]
     if name == 'ReportBackground':
         return self._process_report_background(value)
     if name == 'TagStatCombine':
         return [self._process_tag_stat_combine(v) for v in value]
     if name == 'TagStatLink':
         return [v for v in [self._process_tag_stat_link(v) for v in value] if v]
     if name == 'RemoveKeywords':
         return [v.upper() for v in value]
     return value
Exemplo n.º 4
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.º 5
0
 def _get_lib_by_name(self, name):
     if name in self.libraries:
         return self.libraries[name]
     matches = [lib for lib in self.libraries.values() if eq(lib.name, name)]
     if len(matches) == 1:
         return matches[0]
     self._no_library_found(name, multiple=bool(matches))
Exemplo n.º 6
0
 def _get_time(self, timestamp):
     if not timestamp or utils.eq(timestamp, 'N/A'):
         return None
     try:
         secs = utils.timestamp_to_secs(timestamp, seps=' :.-_')
     except ValueError:
         return None
     return utils.secs_to_timestamp(secs, millis=True)
 def _link_keywords(self, res):
     name = res.group(1)
     lib = self.lib if hasattr(self, 'lib') else self
     for kw in lib.keywords:
         if utils.eq(name, kw.name):
             return '<a href="#%s" class="name">%s</a>' % (kw.name, name)
     if utils.eq_any(name, ['introduction', 'library introduction']):
         return '<a href="#introduction" class="name">%s</a>' % name
     if utils.eq_any(name, ['importing', 'library importing']):
         return '<a href="#importing" class="name">%s</a>' % name
     return '<span class="name">%s</span>' % name
Exemplo n.º 8
0
 def test_eq(self):
     assert eq("foo", "foo")
     assert eq("f OO\t\n", "  foo", caseless=True, spaceless=True)
     assert eq("-a-b-c-", "b", ignore=("-", "a", "c"))
     assert not eq("foo", "bar")
     assert not eq("foo", "FOO", caseless=False)
     assert not eq("foo", "foo ", spaceless=False)
Exemplo n.º 9
0
 def _get_explicit_handler(self, name):
     libname, kwname = self._split_keyword_name(name)
     # 1) Find matching lib(s)
     libs = [lib for lib in self._userlibs + self._testlibs.values()
             if utils.eq(lib.name, libname)]
     if not libs:
         return None
     # 2) Find matching kw from found libs
     found = [lib.get_handler(kwname) for lib in libs
              if lib.has_handler(kwname)]
     if len(found) > 1:
         self._raise_multiple_keywords_found(name, found, implicit=False)
     return found and found[0] or None
Exemplo n.º 10
0
 def _process_value(self, name, value):
     if name in ['Name', 'Doc', 'LogTitle', 'ReportTitle', 'SummaryTitle']:
         return value.replace('_', ' ')
     if name in ['Metadata', 'TagDoc']:
         return [v.replace('_', ' ') for v in value]
     if name in ['Include', 'Exclude', 'TagStatCombine']:
         return [item.replace('AND', '&') for item in value]
     if name in self._optional_outputs and utils.eq(value, 'NONE'):
         return 'NONE'
     if name == 'OutputDir':
         return utils.normpath(value)
     if name in ['SplitOutputs', 'SuiteStatLevel', 'MonitorWidth']:
         return self._convert_to_integer(name, value)
     if name in ['Listeners', 'VariableFiles']:
         return [self._split_args_from_name(item) for item in value]
     if name == 'TagStatLink':
         return self._process_tag_stat_link(value)
     if name == 'RemoveKeywords':
         return value.upper()
     if name == 'MonitorColors':
         return (utils.eq(value, 'ON') and os.sep == '/') \
             or utils.eq(value, 'FORCE')
     return value
 def _get_explicit_handler(self, name):
     libname, kwname = name.rsplit('.', 1)
     # 1) Find matching lib(s)
     libs = [lib for lib
             in chain(self._imported_resource_files.values(), self._testlibs.values())
             if utils.eq(lib.name, libname)]
     if not libs:
         return None
     # 2) Find matching kw from found libs
     found = [lib.get_handler(kwname) for lib in libs
              if lib.has_handler(kwname)]
     if len(found) > 1:
         self._raise_multiple_keywords_found(name, found, implicit=False)
     return found and found[0] or None
 def _get_explicit_handler(self, name):
     libname, kwname = name.rsplit('.', 1)
     # 1) Find matching lib(s)
     libs = [
         lib for lib in chain(self._imported_resource_files.values(),
                              self._testlibs.values())
         if utils.eq(lib.name, libname)
     ]
     if not libs:
         return None
     # 2) Find matching kw from found libs
     found = [
         lib.get_handler(kwname) for lib in libs if lib.has_handler(kwname)
     ]
     if len(found) > 1:
         self._raise_multiple_keywords_found(name, found, implicit=False)
     return found and found[0] or None
Exemplo n.º 13
0
 def _convert(self, value, explicit_type=True):
     enum = self.used_type
     try:
         # This is compatible with the enum module in Python 3.4, its
         # enum34 backport, and the older enum module. `enum[value]`
         # wouldn't work with the old enum module.
         return getattr(enum, value)
     except AttributeError:
         members = sorted(self._get_members(enum))
         matches = [m for m in members if eq(m, value, ignore='_')]
         if not matches:
             raise ValueError("%s does not have member '%s'. Available: %s"
                              % (self.type_name, value, seq2str(members)))
         if len(matches) > 1:
             raise ValueError("%s has multiple members matching '%s'. Available: %s"
                              % (self.type_name, value, seq2str(matches)))
         return getattr(enum, matches[0])
Exemplo n.º 14
0
 def _get_runner_based_on_search_order(self, runners):
     for libname in self.search_order:
         for runner in runners:
             if eq(libname, runner.libname):
                 return [runner]
     return runners
Exemplo n.º 15
0
 def _find_keywords(self, owner_name, name):
     return [
         owner.handlers.create_runner(name) for owner in chain(
             self.libraries.values(), self.resources.values())
         if eq(owner.name, owner_name) and name in owner.handlers
     ]
Exemplo n.º 16
0
 def find_node_with_label(self, node, label):
     matcher = lambda n: utils.eq(self._tree.GetItemText(n), label)
     return self._find_node_with_predicate(node, matcher)
Exemplo n.º 17
0
 def get_url(self, alias):
     for name, url in self._get_aliases_and_urls_from_db():
         if eq(name, alias):
             return url
     return None
 def find_node_with_label(self, node, label):
     matcher = lambda n: utils.eq(self._tree.GetItemText(n), label)
     return self._find_node_with_predicate(node, matcher)
Exemplo n.º 19
0
 def _find_keywords(self, owner_name, name):
     return [owner.handlers[name]
             for owner in self.libraries.values() + self.resources.values()
             if utils.eq(owner.name, owner_name) and name in owner.handlers]
 def get_tests_from_suite(self, suite, name=None):
     tests = [test for test in suite.tests
              if name is None or utils.eq(test.name, name)]
     for subsuite in suite.suites:
         tests.extend(self.get_tests_from_suite(subsuite, name))
     return tests
Exemplo n.º 21
0
 def _find_keywords(self, owner_name, name):
     return [
         owner.handlers[name]
         for owner in self.libraries.values() + self.resources.values()
         if eq(owner.name, owner_name) and name in owner.handlers
     ]
Exemplo n.º 22
0
 def should_contain_keywords(self, item, *kw_names):
     actual_names =  [kw.name for kw in item.keywords]
     utils.asserts.assert_equals(len(actual_names), len(kw_names), 'Wrong number of keywords')
     for act, exp in zip(actual_names, kw_names):
         utils.eq(act, exp)
 def get_url_and_output(self, alias):
     for name, url, output_file in self._get_aliases_urls_and_output_files_from_db():
         if eq(name, alias):
             return url, output_file
     return None, None
Exemplo n.º 24
0
 def should_contain_tags(self, test, *tag_names):
     utils.asserts.assert_equals(len(test.tags), len(tag_names), 'Wrong number of tags')
     for act, exp in zip(test.tags, tag_names):
         utils.eq(act, exp)
Exemplo n.º 25
0
 def _get_handler_based_on_search_order(self, handlers):
     for libname in self.search_order:
         for handler in handlers:
             if utils.eq(libname, handler.libname):
                 return [handler]
     return handlers
Exemplo n.º 26
0
 def _get_runner_based_on_search_order(self, runners):
     for libname in self.search_order:
         for runner in runners:
             if eq(libname, runner.libname):
                 return [runner]
     return runners
Exemplo n.º 27
0
 def _get_suites_from_suite(self, suite, name):
     suites = [suite] if utils.eq(suite.name, name) else []
     for subsuite in suite.suites:
         suites.extend(self._get_suites_from_suite(subsuite, name))
     return suites
 def get_suites_from_suite(self, suite, name):
     suites = [suite] if utils.eq(suite.name, name) else []
     for subsuite in suite.suites:
         suites.extend(self.get_suites_from_suite(subsuite, name))
     return suites
Exemplo n.º 29
0
 def get_tests_from_suite(self, suite, name=None):
     tests = [test for test in suite.tests
              if name is None or utils.eq(test.name, name)]
     for subsuite in suite.suites:
         tests.extend(self.get_tests_from_suite(subsuite, name))
     return tests
 def get_url(self, alias):
     for name, url in self._get_aliases_and_urls_from_db():
         if eq(name, alias):
             return url
     return None
Exemplo n.º 31
0
 def _find_keywords(self, owner_name, name):
     return [owner.handlers.create_runner(name)
             for owner in chain(self.libraries.values(), self.resources.values())
             if eq(owner.name, owner_name) and name in owner.handlers]
Exemplo n.º 32
0
 def should_contain_tags(self, test, *tag_names):
     utils.asserts.assert_equals(len(test.tags), len(tag_names),
                                 'Wrong number of tags')
     for act, exp in zip(test.tags, tag_names):
         utils.eq(act, exp)
Exemplo n.º 33
0
 def _find_keywords(self, owner_name, name):
     return [owner.get_handler(name)
             for owner in self.libraries.values() + self.resources.values()
             if utils.eq(owner.name, owner_name) and owner.has_handler(name)]
Exemplo n.º 34
0
 def should_contain_keywords(self, item, *kw_names):
     actual_names = [kw.name for kw in item.keywords]
     utils.asserts.assert_equals(len(actual_names), len(kw_names),
                                 'Wrong number of keywords')
     for act, exp in zip(actual_names, kw_names):
         utils.eq(act, exp)
Exemplo n.º 35
0
 def get_suites_from_suite(self, suite, name):
     suites = utils.eq(suite.name, name) and [suite] or []
     for subsuite in suite.suites:
         suites.extend(self.get_suites_from_suite(subsuite, name))
     return suites
Exemplo n.º 36
0
 def get_suites_from_suite(self, suite, name):
     suites = utils.eq(suite.name, name) and [ suite ] or []
     for subsuite in suite.suites:
         suites.extend(self.get_suites_from_suite(subsuite, name))
     return suites