本文整理匯總了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")