本文整理匯總了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()
示例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))
示例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))
示例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
示例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)
示例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)
示例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
示例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
示例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)
示例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')
示例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')