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


Python core.run函数代码示例

本文整理汇总了Python中nose.core.run函数的典型用法代码示例。如果您正苦于以下问题:Python run函数的具体用法?Python run怎么用?Python run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了run函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: get_coverage_for_function

def get_coverage_for_function(function, startfile, cover_mech=None, fresh_coverage=True):
    """
    cover_mech = 'coverage'|'figleaf'|None
    >>> get_coverage_for_function('add_argument','../../pylibs/argparse/argparse.py', cover_mech='coverage' )
    """
    # get tests for function
    tf = TestFinder(function, startfile)
    tests = tf.candidate_files(walk_callback)
    
    # run tests with coverage
    # here's how to run specific tests:
    # PYTHONPATH=/home/matt/work/pylibs/argparse/ nosetests  -w /home/matt/work/pylibs/argparse -v path/to/testfile.py:TestClass.test_method path/other.py:TestClass.test_method

    nose_test_cmds = []
    for filename, classname, methodname, line_num in tests:
        nose_test_cmds.append(get_nose_cmd(filename, classname, methodname, line_num))
    nose_argv = ['-v'] + nose_test_cmds + ['-w', os.path.dirname(startfile)]

    if cover_mech == 'coverage':
        # .coverage will be in the -w os.path.dirname(startfile) directory
        nose_argv.append('--with-coverage')
        if fresh_coverage:
            nose_argv.append('--cover-erase')
        # probably should deal with "--cover-package"
    elif cover_mech == 'figleaf':
        pass
    
    print "RUNNING", " ".join(nose_argv)
    core.run(argv=nose_argv)
开发者ID:AndreaCrotti,项目名称:pycoverage.el,代码行数:29,代码来源:findtests.py

示例2: test_run

 def test_run(self):
     with Stub() as selector:
         selector.wantFile(any()) >> False
     with Stub() as run:
         from nose.core import run
         run(argv=any(), addplugins=any()) >> True
     runner = MutationRunner(mutations_path='/mutations/path', test_selector=selector)
     runner.run(None)
开发者ID:FedericoCeratto,项目名称:elcap,代码行数:8,代码来源:test_mutation_plugin.py

示例3: main

def main():
    if os.path.exists('xunit_results'):
        shutil.rmtree('xunit_results')
        os.mkdir('xunit_results')

    numpy.test('full', extra_argv='--with-xunit --xunit-file=xunit_results/numpy_tests.xml'.split())

    run(defaultTest='jasmin_scivm/tests', 
        argv='dummy --with-xunit --xunit-file=xunit_results/jap_tests.xml'.split(),
        exit=False)

    run(defaultTest='cdat_lite', 
        argv='dummy --with-xunit --xunit-file=xunit_results/cdat_tests.xml'.split(),
        exit=False)
开发者ID:cedadev,项目名称:jasmin_scivm,代码行数:14,代码来源:run_tests.py

示例4: run_tests

def run_tests():
    # Consider the directory...
    directory = '.'
    if FLAGS.directory is not None:
        directory = FLAGS.directory

    # Set up the arguments...
    args = [sys.argv[0], '-v', '--exe', directory]

    # Is this a dry run?
    if FLAGS.dry_run:
        args.insert(-2, '--collect-only')
    else:
        # Are we in debug mode?
        if FLAGS.debug:
            args.insert(-2, '--nocapture')

        # Process skip...
        if FLAGS.no_skip:
            args.insert(-2, '--no-skip')
        elif FLAGS.skip:
            args.insert(-2, '--attr=%s' % FLAGS.skip)

    # Run the integration tests
    return core.run(argv=args,
                    addplugins=[Timed(), DepFail(), DependsPlugin()])
开发者ID:Cerberus98,项目名称:backfire,代码行数:26,代码来源:adaptor_nose.py

示例5: run_nose

    def run_nose(self, apps, config_path, paths, project_name):
        from nose.core import run
        from nose.config import Config

        argv = ["-d", "-s", "--verbose"]

        use_coverage = True
        try:
            import coverage
            argv.append("--with-coverage")
            argv.append("--cover-erase")
            #argv.append("--cover-package=%s" % project_name)
            argv.append("--cover-inclusive")
        except ImportError:
            pass

        if exists(config_path):
            argv.append("--config=%s" % config_path)

        for path in paths:
            argv.append(path)
            
        if use_coverage:
            for app in apps:
                argv.append("--cover-package=%s" % app)

        result = run(argv=argv)
        if not result:
            sys.exit(1)
开发者ID:heynemann,项目名称:ion,代码行数:29,代码来源:providers.py

示例6: run

def run():
    logging.setup()
    # If any argument looks like a test name but doesn't have "nova.tests" in
    # front of it, automatically add that so we don't have to type as much
    show_elapsed = True
    argv = []
    for x in sys.argv:
        if x.startswith('test_'):
            argv.append('nova.tests.%s' % x)
        elif x.startswith('--hide-elapsed'):
            show_elapsed = False
        else:
            argv.append(x)

    testdir = os.path.abspath(os.path.join("nova", "tests"))
    c = config.Config(stream=sys.stdout,
                      env=os.environ,
                      verbosity=3,
                      workingDir=testdir,
                      plugins=core.DefaultPluginManager())

    runner = NovaTestRunner(stream=c.stream,
                            verbosity=c.verbosity,
                            config=c,
                            show_elapsed=show_elapsed)
    sys.exit(not core.run(config=c, testRunner=runner, argv=argv))
开发者ID:nicoleLiu,项目名称:nova,代码行数:26,代码来源:runner.py

示例7: run

def run():
    # This is a fix to allow the --hide-elapsed flag while accepting
    # arbitrary nosetest flags as well
    argv = [x for x in sys.argv if x != '--hide-elapsed']
    hide_elapsed = argv != sys.argv
    logging.setup("cinder")

    # If any argument looks like a test name but doesn't have "cinder.tests" in
    # front of it, automatically add that so we don't have to type as much
    for i, arg in enumerate(argv):
        if arg.startswith('test_'):
            argv[i] = 'cinder.tests.%s' % arg

    testdir = os.path.abspath(os.path.join("cinder", "tests"))
    c = config.Config(stream=sys.stdout,
                      env=os.environ,
                      verbosity=3,
                      workingDir=testdir,
                      plugins=core.DefaultPluginManager())

    runner = CinderTestRunner(stream=c.stream,
                              verbosity=c.verbosity,
                              config=c,
                              show_elapsed=not hide_elapsed)
    sys.exit(not core.run(config=c, testRunner=runner, argv=argv))
开发者ID:StackOps,项目名称:cinder,代码行数:25,代码来源:runner.py

示例8: run_tests

def run_tests(c=None):
    # 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 = CrdTestRunner(stream=c.stream, verbosity=c.verbosity, config=c)
    return not core.run(config=c, testRunner=runner)
开发者ID:Open-SFC,项目名称:nscs,代码行数:11,代码来源:test_lib.py

示例9: run

 def run(self):
     try:
         from nose.core import run
     except ImportError:
         raise DistutilsModuleError('nose <http://nose.readthedocs.org/> '
                                    'is needed to run the tests')
     self.run_command('build')
     major, minor = sys.version_info[:2]
     lib_dir = "build/lib.{0}-{1}.{2}".format(get_platform(), major, minor)
     print(header(' Tests '))
     if not run(argv=[__file__, '-v', lib_dir]):
         raise DistutilsError('at least one of the tests failed')
开发者ID:gitter-badger,项目名称:kwant,代码行数:12,代码来源:setup.py

示例10: run_tests

def run_tests(c):
    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)

    runner = QuantumTestRunner(stream=c.stream,
                            verbosity=c.verbosity,
                            config=c)
    return not core.run(config=c, testRunner=runner)
开发者ID:Oneiroi,项目名称:quantum,代码行数:12,代码来源:test_lib.py

示例11: run

def run():
    argv = sys.argv
    stream = sys.stdout
    verbosity = 3
    testdir = os.path.dirname(os.path.abspath(__file__))

    conf = config.Config(stream=stream,
                      env=os.environ,
                      verbosity=verbosity,
                      workingDir=testdir,
                      plugins=core.DefaultPluginManager())

    sys.exit(not core.run(config=conf, argv=argv))
开发者ID:cloudcache,项目名称:mom,代码行数:13,代码来源:testrunner.py

示例12: run

    def run(self, args=None):
        try:
            print 'Running test suite: %s' % self.__class__.__name__

            self.setUp()

            # discover and run tests

            # If any argument looks like a test name but doesn't have
            # "keystone.test" in front of it, automatically add that so we
            # don't have to type as much
            show_elapsed = True
            argv = []
            if args is None:
                args = sys.argv
            has_base = False
            for x in args:
                if x.startswith(('functional', 'unit', 'client')):
                    argv.append('keystone.test.%s' % x)
                    has_base = True
                elif x.startswith('--hide-elapsed'):
                    show_elapsed = False
                elif x.startswith('-'):
                    argv.append(x)
                else:
                    argv.append(x)
                    if x != args[0]:
                        has_base = True

            if not has_base and self.directory_base is not None:
                argv.append(self.directory_base)
            argv = ['--no-path-adjustment'] + argv[1:]
            logger.debug("Running set of tests with args=%s" % argv)

            c = noseconfig.Config(stream=sys.stdout,
                              env=os.environ,
                              verbosity=3,
                              workingDir=TEST_DIR,
                              plugins=core.DefaultPluginManager(),
                              args=argv)

            runner = NovaTestRunner(stream=c.stream,
                                    verbosity=c.verbosity,
                                    config=c,
                                    show_elapsed=show_elapsed)

            result = not core.run(config=c, testRunner=runner, argv=argv)
            return int(result)  # convert to values applicable to sys.exit()
        except Exception, exc:
            logger.exception(exc)
            raise exc
开发者ID:HugoKuo,项目名称:keystone-essex3,代码行数:51,代码来源:__init__.py

示例13: run

def run():
    argv = sys.argv
    stream = sys.stdout
    verbosity = 3
    testdir = os.path.dirname(os.path.abspath(__file__))

    conf = config.Config(
        stream=stream, env=os.environ, verbosity=verbosity, workingDir=testdir, plugins=core.DefaultPluginManager()
    )
    conf.plugins.addPlugin(SlowTestsPlugin())
    conf.plugins.addPlugin(StressTestsPlugin())

    runner = VdsmTestRunner(stream=conf.stream, verbosity=conf.verbosity, config=conf)

    sys.exit(not core.run(config=conf, testRunner=runner, argv=argv))
开发者ID:germanovm,项目名称:vdsm,代码行数:15,代码来源:testlib.py

示例14: main

def main():
    description = ("Runs velvet unit and/or integration tests. "
                   "Arguments will be passed on to nosetests. "
                   "See nosetests --help for more information.")
    parser = argparse.ArgumentParser(description=description)
    known_args, remaining_args = parser.parse_known_args()
    attribute_args = ['-a', '!notdefault']
    all_args = [__file__] + attribute_args + remaining_args
    print "nose command:", ' '.join(all_args)
    if run(argv=all_args):
        # run will return True is all the tests pass.  We want
        # this to equal a 0 rc
        return 0
    else:
        return 1
开发者ID:DareLondon,项目名称:velvet,代码行数:15,代码来源:test.py

示例15: run

    def run(self, args=None):
        try:
            self.setUp()

            # discover and run tests
            # TODO(zns): check if we still need a verbosity flag
            verbosity = 1
            if "--verbose" in sys.argv:
                verbosity = 2

            # If any argument looks like a test name but doesn't have
            # "nova.tests" in front of it, automatically add that so we don't
            # have to type as much
            show_elapsed = True
            argv = []
            if args is None:
                args = sys.argv
            has_base = False
            for x in args:
                if x.startswith(("functional", "unit", "client")):
                    argv.append("keystone.test.%s" % x)
                    has_base = True
                elif x.startswith("--hide-elapsed"):
                    show_elapsed = False
                elif x.startswith("--trace-calls"):
                    pass
                elif x.startswith("--debug"):
                    pass
                elif x.startswith("-"):
                    argv.append(x)
                else:
                    argv.append(x)
                    if x != args[0]:
                        has_base = True

            if not has_base and self.directory_base is not None:
                argv.append(self.directory_base)

            c = noseconfig.Config(
                stream=sys.stdout, env=os.environ, verbosity=3, workingDir=TEST_DIR, plugins=core.DefaultPluginManager()
            )

            runner = NovaTestRunner(stream=c.stream, verbosity=c.verbosity, config=c, show_elapsed=show_elapsed)

            return not core.run(config=c, testRunner=runner, argv=argv + ["--no-path-adjustment"])
        finally:
            self.tearDown()
开发者ID:bodepd,项目名称:keystone,代码行数:47,代码来源:__init__.py


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