本文整理汇总了Python中nose.selector.Selector.matches方法的典型用法代码示例。如果您正苦于以下问题:Python Selector.matches方法的具体用法?Python Selector.matches怎么用?Python Selector.matches使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nose.selector.Selector
的用法示例。
在下文中一共展示了Selector.matches方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_exclude
# 需要导入模块: from nose.selector import Selector [as 别名]
# 或者: from nose.selector.Selector import matches [as 别名]
def test_exclude(self):
s = Selector(Config())
c = Config()
c.exclude = [re.compile(r'me')]
s2 = Selector(c)
assert s.matches('test_foo')
assert s2.matches('test_foo')
assert s.matches('test_me')
assert not s2.matches('test_me')
示例2: SynchroNosePlugin
# 需要导入模块: from nose.selector import Selector [as 别名]
# 或者: from nose.selector.Selector import matches [as 别名]
class SynchroNosePlugin(Plugin):
name = 'synchro'
def __init__(self, *args, **kwargs):
# We need a standard Nose selector in order to filter out methods that
# don't match TestSuite.test_*
self.selector = Selector(config=None)
super(SynchroNosePlugin, self).__init__(*args, **kwargs)
def configure(self, options, conf):
super(SynchroNosePlugin, self).configure(options, conf)
self.enabled = True
def wantModule(self, module):
for module_name in excluded_modules:
if module_name.endswith('*'):
if module.__name__.startswith(module_name.rstrip('*')):
# E.g., test_motor_cursor matches "test_motor_*".
return False
elif module.__name__ == module_name:
return False
return True
def wantMethod(self, method):
# Run standard Nose checks on name, like "does it start with test_"?
if not self.selector.matches(method.__name__):
return False
for excluded_name in excluded_tests:
if PY3:
classname = method.__self__.__class__.__name__
else:
classname = method.im_class.__name__
# Should we exclude this method's whole TestCase?
suite_name, method_name = excluded_name.split('.')
suite_matches = (suite_name == classname or suite_name == '*')
# Should we exclude this particular method?
method_matches = (
method.__name__ == method_name or method_name == '*')
if suite_matches and method_matches:
return False
return True
示例3: SynchroNosePlugin
# 需要导入模块: from nose.selector import Selector [as 别名]
# 或者: from nose.selector.Selector import matches [as 别名]
class SynchroNosePlugin(Plugin):
name = 'synchro'
def __init__(self, *args, **kwargs):
# We need a standard Nose selector in order to filter out methods that
# don't match TestSuite.test_*
self.selector = Selector(config=None)
super(SynchroNosePlugin, self).__init__(*args, **kwargs)
def configure(self, options, conf):
super(SynchroNosePlugin, self).configure(options, conf)
self.enabled = True
def wantModule(self, module):
for module_name in excluded_modules:
if module.__name__.startswith(module_name):
return False
return True
def wantMethod(self, method):
# Run standard Nose checks on name, like "does it start with test_"?
if not self.selector.matches(method.__name__):
return False
for excluded_name in excluded_tests:
suite_name, method_name = excluded_name.split('.')
suite_matches = (
method.im_class.__name__ == suite_name or suite_name == '*')
method_matches = (
method.__name__ == method_name or method_name == '*')
if suite_matches and method_matches:
return False
return True
示例4: test_include
# 需要导入模块: from nose.selector import Selector [as 别名]
# 或者: from nose.selector.Selector import matches [as 别名]
def test_include(self):
s = Selector(Config())
c = Config()
c.include = [re.compile(r'me')]
s2 = Selector(c)
assert s.matches('test')
assert s2.matches('test')
assert not s.matches('meatball')
assert s2.matches('meatball')
assert not s.matches('toyota')
assert not s2.matches('toyota')
c.include.append(re.compile('toy'))
assert s.matches('test')
assert s2.matches('test')
assert not s.matches('meatball')
assert s2.matches('meatball')
assert not s.matches('toyota')
assert s2.matches('toyota')
示例5: SynchroNosePlugin
# 需要导入模块: from nose.selector import Selector [as 别名]
# 或者: from nose.selector.Selector import matches [as 别名]
class SynchroNosePlugin(Plugin):
name = 'synchro'
def __init__(self, *args, **kwargs):
# We need a standard Nose selector in order to filter out methods that
# don't match TestSuite.test_*
self.selector = Selector(config=None)
super(SynchroNosePlugin, self).__init__(*args, **kwargs)
def configure(self, options, conf):
super(SynchroNosePlugin, self).configure(options, conf)
self.enabled = True
def wantModule(self, module):
# Depending on PYTHONPATH, Motor's direct tests may be imported - don't
# run them now.
if module.__name__.startswith('test.test_motor_'):
return False
for module_name in excluded_modules:
if module_name.endswith('*'):
if module.__name__.startswith(module_name.rstrip('*')):
# E.g., test_motor_cursor matches "test_motor_*".
excluded_modules_matched.add(module_name)
return False
elif module.__name__ == module_name:
excluded_modules_matched.add(module_name)
return False
return True
def wantFunction(self, fn):
# PyMongo's test generators run at import time; tell Nose not to run
# them as unittests.
if fn.__name__ in ('test_cases',
'create_test',
'create_selection_tests'):
return False
def wantMethod(self, method):
# Run standard Nose checks on name, like "does it start with test_"?
if not self.selector.matches(method.__name__):
return False
for excluded_name in excluded_tests:
if PY3:
classname = method.__self__.__class__.__name__
else:
classname = method.im_class.__name__
# Should we exclude this method's whole TestCase?
suite_name, method_name = excluded_name.split('.')
suite_matches = (suite_name == classname or suite_name == '*')
# Should we exclude this particular method?
method_matches = (
method.__name__ == method_name or method_name == '*')
if suite_matches and method_matches:
excluded_tests_matched.add(excluded_name)
return False
return True
示例6: test_include
# 需要导入模块: from nose.selector import Selector [as 别名]
# 或者: from nose.selector.Selector import matches [as 别名]
def test_include(self):
s = Selector(Config())
c = Config()
c.include = [re.compile(r"me")]
s2 = Selector(c)
assert s.matches("test")
assert s2.matches("test")
assert not s.matches("meatball")
assert s2.matches("meatball")
assert not s.matches("toyota")
assert not s2.matches("toyota")
c.include.append(re.compile("toy"))
assert s.matches("test")
assert s2.matches("test")
assert not s.matches("meatball")
assert s2.matches("meatball")
assert not s.matches("toyota")
assert s2.matches("toyota")