当前位置: 首页>>代码示例>>Python>>正文


Python nose.config方法代码示例

本文整理汇总了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 
开发者ID:singhj,项目名称:locality-sensitive-hashing,代码行数:26,代码来源:core.py

示例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) 
开发者ID:singhj,项目名称:locality-sensitive-hashing,代码行数:22,代码来源:core.py

示例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 
开发者ID:singhj,项目名称:locality-sensitive-hashing,代码行数:19,代码来源:core.py

示例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) 
开发者ID:singhj,项目名称:locality-sensitive-hashing,代码行数:27,代码来源:core.py

示例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 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:23,代码来源:core.py

示例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) 
开发者ID:OpenState-SDN,项目名称:ryu,代码行数:22,代码来源:test_lib.py

示例7: _makeResult

# 需要导入模块: import nose [as 别名]
# 或者: from nose import config [as 别名]
def _makeResult(self):
        return TextTestResult(self.stream,
                              self.descriptions,
                              self.verbosity,
                              self.config) 
开发者ID:singhj,项目名称:locality-sensitive-hashing,代码行数:7,代码来源:core.py

示例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) 
开发者ID:singhj,项目名称:locality-sensitive-hashing,代码行数:13,代码来源:core.py

示例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 
开发者ID:singhj,项目名称:locality-sensitive-hashing,代码行数:36,代码来源:core.py

示例10: configure

# 需要导入模块: import nose [as 别名]
# 或者: from nose import config [as 别名]
def configure(self, options, config):
        pass 
开发者ID:singhj,项目名称:locality-sensitive-hashing,代码行数:4,代码来源:manager.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:13,代码来源:core.py

示例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) 
开发者ID:chestm007,项目名称:linux_thermaltake_riing,代码行数:10,代码来源:run_tests.py

示例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 
开发者ID:ufora,项目名称:ufora,代码行数:16,代码来源:test.py

示例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 
开发者ID:ufora,项目名称:ufora,代码行数:10,代码来源:UnitTestCommon.py

示例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) 
开发者ID:ufora,项目名称:ufora,代码行数:6,代码来源:UnitTestCommon.py


注:本文中的nose.config方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。