本文整理汇总了Python中nose.config方法的典型用法代码示例。如果您正苦于以下问题:Python nose.config方法的具体用法?Python nose.config怎么用?Python nose.config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nose
的用法示例。
在下文中一共展示了nose.config方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: import nose [as 别名]
# 或者: from nose import config [as 别名]
def run(self, test):
"""Overrides to provide plugin hooks and defer all output to
the test result class.
"""
wrapper = self.config.plugins.prepareTest(test)
if wrapper is not None:
test = wrapper
# plugins can decorate or capture the output stream
wrapped = self.config.plugins.setOutputStream(self.stream)
if wrapped is not None:
self.stream = wrapped
result = self._makeResult()
start = time.time()
try:
test(result)
except KeyboardInterrupt:
pass
stop = time.time()
result.printErrors()
result.printSummary(start, stop)
self.config.plugins.finalize(result)
return result
示例2: __init__
# 需要导入模块: import nose [as 别名]
# 或者: from nose import config [as 别名]
def __init__(self, module=None, defaultTest='.', argv=None,
testRunner=None, testLoader=None, env=None, config=None,
suite=None, exit=True, plugins=None, addplugins=None):
if env is None:
env = os.environ
if config is None:
config = self.makeConfig(env, plugins)
if addplugins:
config.plugins.addPlugins(extraplugins=addplugins)
self.config = config
self.suite = suite
self.exit = exit
extra_args = {}
version = sys.version_info[0:2]
if version >= (2,7) and version != (3,0):
extra_args['exit'] = exit
unittest.TestProgram.__init__(
self, module=module, defaultTest=defaultTest,
argv=argv, testRunner=testRunner, testLoader=testLoader,
**extra_args)
示例3: runTests
# 需要导入模块: import nose [as 别名]
# 或者: from nose import config [as 别名]
def runTests(self):
"""Run Tests. Returns true on success, false on failure, and sets
self.success to the same value.
"""
log.debug("runTests called")
if self.testRunner is None:
self.testRunner = TextTestRunner(stream=self.config.stream,
verbosity=self.config.verbosity,
config=self.config)
plug_runner = self.config.plugins.prepareTestRunner(self.testRunner)
if plug_runner is not None:
self.testRunner = plug_runner
result = self.testRunner.run(self.test)
self.success = result.wasSuccessful()
if self.exit:
sys.exit(not self.success)
return self.success
示例4: collector
# 需要导入模块: import nose [as 别名]
# 或者: from nose import config [as 别名]
def collector():
"""TestSuite replacement entry point. Use anywhere you might use a
unittest.TestSuite. The collector will, by default, load options from
all config files and execute loader.loadTestsFromNames() on the
configured testNames, or '.' if no testNames are configured.
"""
# plugins that implement any of these methods are disabled, since
# we don't control the test runner and won't be able to run them
# finalize() is also not called, but plugins that use it aren't disabled,
# because capture needs it.
setuptools_incompat = ('report', 'prepareTest',
'prepareTestLoader', 'prepareTestRunner',
'setOutputStream')
plugins = RestrictedPluginManager(exclude=setuptools_incompat)
conf = Config(files=all_config_files(),
plugins=plugins)
conf.configure(argv=['collector'])
loader = defaultTestLoader(conf)
if conf.testNames:
suite = loader.loadTestsFromNames(conf.testNames)
else:
suite = loader.loadTestsFromNames(('.',))
return FinalizingSuiteWrapper(suite, plugins.finalize)
示例5: run
# 需要导入模块: import nose [as 别名]
# 或者: from nose import config [as 别名]
def run(self, test):
"""Overrides to provide plugin hooks and defer all output to
the test result class.
"""
wrapper = self.config.plugins.prepareTest(test)
if wrapper is not None:
test = wrapper
# plugins can decorate or capture the output stream
wrapped = self.config.plugins.setOutputStream(self.stream)
if wrapped is not None:
self.stream = wrapped
result = self._makeResult()
start = time.time()
test(result)
stop = time.time()
result.printErrors()
result.printSummary(start, stop)
self.config.plugins.finalize(result)
return result
示例6: run_tests
# 需要导入模块: import nose [as 别名]
# 或者: from nose import config [as 别名]
def run_tests(c=None):
logger = logging.getLogger()
hdlr = logging.StreamHandler()
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.DEBUG)
# NOTE(bgh): I'm not entirely sure why but nose gets confused here when
# calling run_tests from a plugin directory run_tests.py (instead of the
# main run_tests.py). It will call run_tests with no arguments and the
# testing of run_tests will fail (though the plugin tests will pass). For
# now we just return True to let the run_tests test pass.
if not c:
return True
runner = RyuTestRunner(stream=c.stream,
verbosity=c.verbosity,
config=c)
return not core.run(config=c, testRunner=runner)
示例7: _makeResult
# 需要导入模块: import nose [as 别名]
# 或者: from nose import config [as 别名]
def _makeResult(self):
return TextTestResult(self.stream,
self.descriptions,
self.verbosity,
self.config)
示例8: makeConfig
# 需要导入模块: import nose [as 别名]
# 或者: from nose import config [as 别名]
def makeConfig(self, env, plugins=None):
"""Load a Config, pre-filled with user config files if any are
found.
"""
cfg_files = self.getAllConfigFiles(env)
if plugins:
manager = PluginManager(plugins=plugins)
else:
manager = DefaultPluginManager()
return Config(
env=env, files=cfg_files, plugins=manager)
示例9: showPlugins
# 需要导入模块: import nose [as 别名]
# 或者: from nose import config [as 别名]
def showPlugins(self):
"""Print list of available plugins.
"""
import textwrap
class DummyParser:
def __init__(self):
self.options = []
def add_option(self, *arg, **kw):
self.options.append((arg, kw.pop('help', '')))
v = self.config.verbosity
self.config.plugins.sort()
for p in self.config.plugins:
print "Plugin %s" % p.name
if v >= 2:
print " score: %s" % p.score
print '\n'.join(textwrap.wrap(p.help().strip(),
initial_indent=' ',
subsequent_indent=' '))
if v >= 3:
parser = DummyParser()
p.addOptions(parser)
if len(parser.options):
print
print " Options:"
for opts, help in parser.options:
print ' %s' % (', '.join(opts))
if help:
print '\n'.join(
textwrap.wrap(help.strip(),
initial_indent=' ',
subsequent_indent=' '))
print
示例10: configure
# 需要导入模块: import nose [as 别名]
# 或者: from nose import config [as 别名]
def configure(self, options, config):
pass
示例11: makeConfig
# 需要导入模块: import nose [as 别名]
# 或者: from nose import config [as 别名]
def makeConfig(self, env, plugins=None):
"""Load a Config, pre-filled with user config files if any are
found.
"""
cfg_files = all_config_files()
if plugins:
manager = PluginManager(plugins=plugins)
else:
manager = DefaultPluginManager()
return Config(
env=env, files=cfg_files, plugins=manager)
示例12: __init__
# 需要导入模块: import nose [as 别名]
# 或者: from nose import config [as 别名]
def __init__(self, stream=sys.stderr, descriptions=1, verbosity=1,
config=None, slow_test_threshold=1.0):
self.slow_test_threshold = slow_test_threshold
if config is None:
config = Config()
self.config = config
self.result_class = TimeLoggingTestResult
unittest.TextTestRunner.__init__(self, stream, descriptions, verbosity)
示例13: runPyTestSuite
# 需要导入模块: import nose [as 别名]
# 或者: from nose import config [as 别名]
def runPyTestSuite(config, testFiles, testCasesToRun, testArgs):
cov = startCoverageCollectionIfEnabled()
with AssertStableThreadCount.AssertStableThreadCount():
testProgram = nose.core.TestProgram(
config=config,
defaultTest=testFiles,
suite=testCasesToRun,
argv=testArgs,
exit=False
)
stopCoverageCollectionIfEnabled(cov)
return not testProgram.success
示例14: loadTestsFromModules
# 需要导入模块: import nose [as 别名]
# 或者: from nose import config [as 别名]
def loadTestsFromModules(config, modules):
loader = nose.loader.TestLoader(config = config)
allSuites = []
for module in modules:
cases = loader.loadTestsFromModule(module)
allSuites.append(cases)
return allSuites
示例15: loadTestCases
# 需要导入模块: import nose [as 别名]
# 或者: from nose import config [as 别名]
def loadTestCases(config, testFiles, rootDir, rootModule):
modules = sortedBy(loadTestModules(testFiles, rootDir, rootModule), lambda module: module.__name__)
allSuites = loadTestsFromModules(config, modules)
return extractTestCases(allSuites)