當前位置: 首頁>>代碼示例>>Python>>正文


Python MultiMatcher.match方法代碼示例

本文整理匯總了Python中robot.utils.MultiMatcher.match方法的典型用法代碼示例。如果您正苦於以下問題:Python MultiMatcher.match方法的具體用法?Python MultiMatcher.match怎麽用?Python MultiMatcher.match使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在robot.utils.MultiMatcher的用法示例。


在下文中一共展示了MultiMatcher.match方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from robot.utils import MultiMatcher [as 別名]
# 或者: from robot.utils.MultiMatcher import match [as 別名]
class TagStatistics:

    def __init__(self, include=None, exclude=None, combine=None, docs=None,
                 links=None):
        self.stats = NormalizedDict(ignore=['_'])
        self._include = MultiMatcher(include, ignore=['_'])
        self._exclude = MultiMatcher(exclude, ignore=['_'])
        self._combine = combine or []
        info = TagStatInfo(docs or [], links or [])
        self._get_doc = info.get_doc
        self._get_links = info.get_links

    def add_test(self, test, critical):
        self._add_tags_statistics(test, critical)
        self._add_combined_statistics(test)

    def _add_tags_statistics(self, test, critical):
        for tag in test.tags:
            if not self._is_included(tag):
                continue
            if tag not in self.stats:
                self.stats[tag] = TagStat(tag, self._get_doc(tag),
                                          self._get_links(tag),
                                          critical.is_critical(tag),
                                          critical.is_non_critical(tag))
            self.stats[tag].add_test(test)

    def _is_included(self, tag):
        if self._include and not self._include.match(tag):
            return False
        return not self._exclude.match(tag)

    def _add_combined_statistics(self, test):
        for pattern, name in self._combine:
            name = name or pattern
            if name not in self.stats:
                self.stats[name] = TagStat(name, self._get_doc(name),
                                           self._get_links(name),
                                           combined=pattern)
            if TagPatterns(pattern).match(test.tags):
                self.stats[name].add_test(test)

    def serialize(self, serializer):
        serializer.start_tag_stats(self)
        for stat in sorted(self.stats.values()):
            stat.serialize(serializer)
        serializer.end_tag_stats(self)

    def sort(self):
        for stat in self.stats.values():
            stat.tests.sort()
開發者ID:AppsFuel,項目名稱:sublime-robot-plugin,代碼行數:53,代碼來源:statistics.py

示例2: test_exclude

# 需要導入模塊: from robot.utils import MultiMatcher [as 別名]
# 或者: from robot.utils.MultiMatcher import match [as 別名]
 def test_exclude(self):
     for excl, tags in self._incl_excl_data:
         builder = TagStatisticsBuilder(excluded=excl)
         builder.add_test(TestCase(status='PASS', tags=tags))
         matcher = MultiMatcher(excl)
         expected = [tag for tag in tags if not matcher.match(tag)]
         assert_equal([s.name for s in builder.stats], sorted(expected))
開發者ID:BanerjeeSandipan,項目名稱:robotframework,代碼行數:9,代碼來源:test_tagstatistics.py

示例3: test_include

# 需要導入模塊: from robot.utils import MultiMatcher [as 別名]
# 或者: from robot.utils.MultiMatcher import match [as 別名]
 def test_include(self):
     for incl, tags in self._incl_excl_data:
         builder = TagStatisticsBuilder(Criticality(), incl, [])
         builder.add_test(TestCase(status='PASS', tags=tags))
         matcher = MultiMatcher(incl, match_if_no_patterns=True)
         expected = [tag for tag in tags if matcher.match(tag)]
         assert_equal([s.name for s in builder.stats], sorted(expected))
開發者ID:synsun,項目名稱:robotframework,代碼行數:9,代碼來源:test_tagstatistics.py

示例4: FlattenKeywordMatcher

# 需要導入模塊: from robot.utils import MultiMatcher [as 別名]
# 或者: from robot.utils.MultiMatcher import match [as 別名]
class FlattenKeywordMatcher(object):

    def __init__(self, flattened):
        self._types = []
        names = self._yield_names_and_set_types(flattened, self._types)
        self._name_matcher = MultiMatcher(names)

    def _yield_names_and_set_types(self, flattened, types):
        if isinstance(flattened, basestring):
            flattened = [flattened]
        for flat in flattened:
            upper = flat.upper()
            if upper in ('FOR', 'FORITEM'):
                types.append(flat.lower())
            elif upper.startswith('NAME:'):
                yield flat[5:]
            else:
                raise DataError("Expected 'FOR', 'FORITEM', or "
                                "'NAME:<pattern>' but got '%s'." % flat)

    def match_name(self, kwname, libname=None):
        name = '%s.%s' % (libname, kwname) if libname else kwname
        return self._name_matcher.match(name)

    def match_type(self, kwtype):
        return kwtype in self._types
開發者ID:Pascale22,項目名稱:robotframework,代碼行數:28,代碼來源:flattenkeywordmatcher.py

示例5: FlattenByNameMatcher

# 需要導入模塊: from robot.utils import MultiMatcher [as 別名]
# 或者: from robot.utils.MultiMatcher import match [as 別名]
class FlattenByNameMatcher(object):

    def __init__(self, flatten):
        if not is_list_like(flatten):
            flatten = [flatten]
        names = [n[5:] for n in flatten if n[:5].lower() == 'name:']
        self._matcher = MultiMatcher(names)

    def match(self, kwname, libname=None):
        name = '%s.%s' % (libname, kwname) if libname else kwname
        return self._matcher.match(name)

    def __nonzero__(self):
        return bool(self._matcher)
開發者ID:toonst,項目名稱:robotframework,代碼行數:16,代碼來源:flattenkeywordmatcher.py

示例6: _NamePatterns

# 需要導入模塊: from robot.utils import MultiMatcher [as 別名]
# 或者: from robot.utils.MultiMatcher import match [as 別名]
class _NamePatterns(object):

    def __init__(self, patterns=None):
        self._matcher = MultiMatcher(patterns, ignore=['_'])

    def match(self, name, longname=None):
        return self._match(name) or longname and self._match_longname(longname)

    def _match(self, name):
        return self._matcher.match(name)

    def _match_longname(self, name):
        raise NotImplementedError

    def __nonzero__(self):
        return bool(self._matcher)
開發者ID:Acidburn0zzz,項目名稱:RIDE,代碼行數:18,代碼來源:namepatterns.py

示例7: FlattenKeywordMatcher

# 需要導入模塊: from robot.utils import MultiMatcher [as 別名]
# 或者: from robot.utils.MultiMatcher import match [as 別名]
class FlattenKeywordMatcher(object):
    def __init__(self, flattened):
        self._types = []
        names = self._yield_names_and_set_types(flattened, self._types)
        self._name_matcher = MultiMatcher(names)

    def _yield_names_and_set_types(self, flattened, types):
        if isinstance(flattened, string_types):
            flattened = [flattened]
        for flat in flattened:
            upper = flat.upper()
            if upper in ("FOR", "FORITEM"):
                types.append(flat.lower())
            elif upper.startswith("NAME:"):
                yield flat[5:]
            else:
                raise DataError("Expected 'FOR', 'FORITEM', or " "'NAME:<pattern>' but got '%s'." % flat)

    def match(self, name, type):
        return self._name_matcher.match(name) or type in self._types
開發者ID:userzimmermann,項目名稱:robotframework-python3,代碼行數:22,代碼來源:flattenkeywordmatcher.py

示例8: search

# 需要導入模塊: from robot.utils import MultiMatcher [as 別名]
# 或者: from robot.utils.MultiMatcher import match [as 別名]
 def search(self, patterns):
     matcher = MultiMatcher(patterns, match_if_no_patterns=True)
     for kw in self._keywords:
         if matcher.match(kw.name):
             yield kw
開發者ID:BanerjeeSandipan,項目名稱:robotframework,代碼行數:7,代碼來源:consoleviewer.py

示例9: test_regexp_single_string_is_converted_to_list

# 需要導入模塊: from robot.utils import MultiMatcher [as 別名]
# 或者: from robot.utils.MultiMatcher import match [as 別名]
 def test_regexp_single_string_is_converted_to_list(self):
     matcher = MultiMatcher('one string', regexp=True)
     assert matcher.match('one string')
     assert not matcher.match('o')
     assert_equal(len(matcher), 1)
開發者ID:HelioGuilherme66,項目名稱:robotframework,代碼行數:7,代碼來源:test_match.py

示例10: test_match_regexp_pattern

# 需要導入模塊: from robot.utils import MultiMatcher [as 別名]
# 或者: from robot.utils.MultiMatcher import match [as 別名]
 def test_match_regexp_pattern(self):
     matcher = MultiMatcher(['xxx', 'f.*'], ignore='_:', regexp=True)
     assert matcher.match('xxx')
     assert matcher.match('foo')
     assert matcher.match('__::FOO::__')
     assert not matcher.match('bar')
開發者ID:HelioGuilherme66,項目名稱:robotframework,代碼行數:8,代碼來源:test_match.py

示例11: test_match_pattern

# 需要導入模塊: from robot.utils import MultiMatcher [as 別名]
# 或者: from robot.utils.MultiMatcher import match [as 別名]
 def test_match_pattern(self):
     matcher = MultiMatcher(['xxx', 'f*'], ignore='.:')
     assert matcher.match('xxx')
     assert matcher.match('foo')
     assert matcher.match('..::FOO::..')
     assert not matcher.match('bar')
開發者ID:HelioGuilherme66,項目名稱:robotframework,代碼行數:8,代碼來源:test_match.py


注:本文中的robot.utils.MultiMatcher.match方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。