• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python nose.run函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: run

def run(verbosity=1,doctest=False):
    """Run NetworkX tests.

    Parameters
    ----------
    verbosity: integer, optional
      Level of detail in test reports.  Higher numbers provide  more detail.  

    doctest: bool, optional
      True to run doctests in code modules
    """
    try:
        import nose
    except ImportError:
        raise ImportError(\
            "The nose package is needed to run the NetworkX tests.")

    sys.stderr.write("Running NetworkX tests:")
    
    nx_install_dir=path.join(path.dirname(__file__), path.pardir)
    argv=[' ','--verbosity=%d'%verbosity,
          '-w',nx_install_dir,
          '-exe']
    if doctest:
        argv.extend(['--with-doctest','--doctest-extension=txt'])

    nose.run(argv=argv)
开发者ID:AhmedPho,项目名称:NetworkX_fork,代码行数:27,代码来源:test.py


示例2: run_nose

def run_nose(module='opengeo.test', open=False):
    '''run tests via nose
    module - defaults to 'opengeo.test' but provide a specific module or test
             like 'package.module' or 'package.module:class' or
             'package.module:class.test'
    open - open results in browser
    '''

    print 'writing test output to %s' % output_dir

    # and only those in this package
    nose_args = base_nose_args + [module]

    # if anything goes bad, nose tries to call usage so hack this in place
    sys.argv = ['nose']
    try:
        # ugly - coverage will plop down it's file in cwd potentially causing
        # failures if not writable
        cwd = os.getcwd()
        os.chdir(output_dir)
        nose.run(exit=False, argv=nose_args, addplugins=[HTML()])
    except SystemExit:
        # keep invalid options from killing everything
        # optparse calls sys.exit
        pass
    finally:
        sys.argv = None
        # change back to original directory
        os.chdir(cwd)

    if open:
        webbrowser.open(join(coverage_dir, 'index.html'))
        webbrowser.open(html_file)
开发者ID:Georepublic,项目名称:suite-qgis-plugin,代码行数:33,代码来源:nosetests.py


示例3: runmodels

def runmodels():
    print " -- running model tests"
    testdir = os.path.normpath('./tests/models/')
    configfile = os.path.join(os.path.normpath('./config/'), "nose.cfg")
    argv = [ configfile,testdir]
    nose.run(argv=argv)
    return
开发者ID:djoudi,项目名称:pow_devel,代码行数:7,代码来源:runtests.py


示例4: test

def test(attr="quick", verbose=False):
    """Run tests.
       
       verbose=True corresponds to nose verbosity=1
       attrib = "quick", "acpt", "all"
    """
    path_to_mcba = os.path.abspath(os.path.dirname(mcba.__file__))
    curr_path = os.getcwd()

    # nose seems to go nuts is run from the directory just above mcba:
    if os.path.join(curr_path, 'mcba') == path_to_mcba:
        mesg = "Please exit the mcba source tree and relaunch " 
        mesg += "your interpreter from somewhere else." 
        print(mesg)
        return False

    argv = ["-w", path_to_mcba, "--all-modules" ]
    if verbose:
        argv += ["-v"]

    #sort out the test attributes
    attr_dct = {"quick": ["-a attrib=quick", "--with-doctest"],
                "acpt": ["-a attrib=acpt"], 
                "all": [""]
               }
    argv += attr_dct[attr]  

    nose.run(argv=argv)
开发者ID:ev-br,项目名称:mcba,代码行数:28,代码来源:testing.py


示例5: main

def main():
    print("      _             _                     _               _            _               _ _       _ ")
    print("     | |           | |                   | |             | |          | |             (_) |     | |")
    print("  ___| |_ __ _ _ __| |_   _ __  _   _  __| |_ __   __ _  | |_ ___  ___| |_   ___ _   _ _| |_ ___| |")
    print(" / __| __/ _` | '__| __| | '_ \| | | |/ _` | '_ \ / _` | | __/ _ \/ __| __| / __| | | | | __/ _ \ |")
    print(" \__ \ || (_| | |  | |_  | |_) | |_| | (_| | | | | (_| | | ||  __/\__ \ |_  \__ \ |_| | | ||  __/_|")
    print(" |___/\__\__,_|_|   \__| | .__/ \__, |\__,_|_| |_|\__,_|  \__\___||___/\__| |___/\__,_|_|\__\___(_)")
    print("                         | |     __/ |                                                             ")
    print("                         |_|    |___/                                                              ")
    print("")

    cwd = os.getcwd()
    abspath = os.path.abspath(__file__)
    dname = os.path.dirname(abspath)
    os.chdir(os.path.join(dname, "tests"))
    nose.run(argv=[__file__, "--all-modules", "--verbosity=3", "--nocapture", "--with-doctest", "--doctest-options=+ELLIPSIS"])
    os.chdir(os.path.join(dname,"pydna"))
    nose.run(argv=[__file__, "--all-modules", "--verbosity=3", "--nocapture", "--with-doctest", "--doctest-options=+ELLIPSIS"])
    os.chdir(cwd)

    print("cache files", os.listdir( os.environ["pydna_data_dir"] ))

    print("                  _               _            _               _ _          __ _       _     _              _ _ ")
    print("                 | |             | |          | |             (_) |        / _(_)     (_)   | |            | | |")
    print("  _ __  _   _  __| |_ __   __ _  | |_ ___  ___| |_   ___ _   _ _| |_ ___  | |_ _ _ __  _ ___| |__   ___  __| | |")
    print(" | '_ \| | | |/ _` | '_ \ / _` | | __/ _ \/ __| __| / __| | | | | __/ _ \ |  _| | '_ \| / __| '_ \ / _ \/ _` | |")
    print(" | |_) | |_| | (_| | | | | (_| | | ||  __/\__ \ |_  \__ \ |_| | | ||  __/ | | | | | | | \__ \ | | |  __/ (_| |_|")
    print(" | .__/ \__, |\__,_|_| |_|\__,_|  \__\___||___/\__| |___/\__,_|_|\__\___| |_| |_|_| |_|_|___/_| |_|\___|\__,_(_)")
    print(" | |     __/ | ")
    print(" |_|    |___/  ")
    print("")
开发者ID:souravsingh,项目名称:pydna,代码行数:31,代码来源:run_test_.py


示例6: main

def main(argv):
    
    wingtest_common.SetupSysArgv(argv)
    
    dirname = wingtest_common.process_directory_arg(argv)
    
    # Assume all args not starting with - are filenames for tests
    for i, arg in enumerate(argv):
        if not arg.startswith('-') and not os.path.isabs(arg):
            argv[i] = os.path.join(dirname, arg)
    
    argv.append('--nocapture')
    
    result = NoseTestResults(sys.stdout)
    runner = wingtest_common.XmlTestRunner(result)
    try:
        try:
            nose.run(argv=argv, testRunner=runner)
        except SystemExit:
            raise
        except Exception:
            # Note that import error from test files end up here, so this is
            # not just for runner exceptions
            if isinstance(xmlout, wingtest_common.XmlStream):
                xmlout._write_exc_info(sys.exc_info())
            else:
                exc_type, exc, tb = sys.exc_info()
                sys.excepthook(exc_type, exc, tb)
    finally:
        xmlout.finish()
开发者ID:aorfi,项目名称:2015-2016-Backup,代码行数:30,代码来源:run_nosetests_xml.py


示例7: _test

 def _test(verbose=False):
     """Invoke the skimage test suite."""
     import nose
     args = ['', pkg_dir, '--exe']
     if verbose:
         args.extend(['-v', '-s'])
     nose.run('skimage', argv=args)
开发者ID:Autodidact24,项目名称:scikit-image,代码行数:7,代码来源:__init__.py


示例8: run_nose

def run_nose(module='opengeo.test', open=False):
    '''run tests via nose
    module - defaults to 'opengeo.test' but provide a specific module or test
             like 'package.module' or 'package.module:class' or
             'package.module:class.test'
    open - open results in browser
    '''

    # and only those in this package
    nose_args = base_nose_args + [module]

    # if anything goes bad, nose tries to call usage so hack this in place
    sys.argv = ['nose']
    try:
        nose.run(exit=False, argv=nose_args, addplugins=[HTML()])
    except SystemExit:
        # keep invalid options from killing everything
        # optparse calls sys.exit
        pass
    finally:
        sys.argv = None

    if open:
        webbrowser.open(join(coverage_dir, 'index.html'))
        webbrowser.open(html_file)
开发者ID:menegon,项目名称:suite-qgis-plugin,代码行数:25,代码来源:nosetests.py


示例9: run

def run(bonus_args=[]):
    # always test the sphinxcontrib.feed package from this directory
    sys.path.insert(0, path.join(path.dirname(__file__), path.pardir))
    sys.path.insert(1, path.abspath(
      path.join(path.dirname(__file__),
      path.pardir,
      'sphinxcontrib', 'feed'))
    )
    try:
        import nose
    except ImportError:
        print "The nose package is needed to run the sphinxcontrib.feed test suite."
        sys.exit(1)

    try:
        import sphinx
    except ImportError:
        print "The sphinx package is needed to run the sphinxcontrib.feed test suite."

    nose_argv = ['nosetests']
    

    # Everything after '--' is passed to nose.
    if '--' in sys.argv:
        hyphen_pos = sys.argv.index('--')
        nose_argv.extend(bonus_args + sys.argv[hyphen_pos + 1:])

    print "Running sphinxcontrib.feed test suite..."
    nose.run(argv=nose_argv)
开发者ID:dantleech,项目名称:doctrine-website-sphinx,代码行数:29,代码来源:run.py


示例10: main

def main():
    if not nose.run(defaultTest='mzb_local_tests'):
        raise RuntimeError("some tests failed")

    with start_mzbench_server():
        if not nose.run(defaultTest=['mzb_basic_tests', 'mzb_signal_tests', 'mzb_negative_tests']):
            raise RuntimeError("some tests failed")
开发者ID:bks7,项目名称:mzbench,代码行数:7,代码来源:run_tests.py


示例11: runsuite

def runsuite():
    funcs = [m[1] for m in
             inspect.getmembers(TestCase, inspect.ismethod)]
    print funcs
    nose.run(suite=ContextSuite(
        tests=funcs,
        context=TestCase))
开发者ID:quodlibetor,项目名称:test-loading-experiment,代码行数:7,代码来源:scripts.py


示例12: run

    def run(self):
        if self.distribution.tests_require:
            self.distribution.fetch_build_eggs(self.distribution.tests_require)

        script_path = sys.path[0]
        tests = []
        lib_dir = os.path.join(script_path, "lib")
        for mod in os.listdir(lib_dir):
            path = os.path.join(lib_dir, mod)
            if mod != ".svn" and os.path.exists(os.path.join(path, "tests")):
                tests.append("%s.tests" % mod)

        if not tests:
            raise CommandError("No tests found in %s/*/tests" % lib_dir)

        if self.system_tests:
            regexp_pat = r"--match=^[Ss]ystem"
        else:
            regexp_pat = r"--match=^([Tt]est(?![Mm]ixin)|[Ss]ystem)"

        n_processors = max(multiprocessing.cpu_count() - 1, 1)

        for test in tests:
            print
            print "Running test discovery on %s with %s processors." % (test, n_processors)
            # run the tests at module level i.e. my_module.tests
            # - test must start with test/Test and must not contain the word Mixin.
            nose.run(
                argv=["", test, "--processes=%s" % n_processors, "--verbosity=2", regexp_pat, "--process-timeout=250"]
            )
开发者ID:smbz,项目名称:iris,代码行数:30,代码来源:setup.py


示例13: execute

	def execute(test, nose_argv = None):
		"""Execute the regression test by using nose with the nose arguments
		and with -d -s --verbosity=2" and --with-xunit (xml generated)
		"""
		test_module = importlib.import_module("test.regression.%s" % test)

		if test_module.__dict__.has_key("__all__"):

			for test_class in test_module.__all__:
				test_object = getattr(test_module, test_module.__all__[0])
				test_suite = unittest.TestLoader().loadTestsFromTestCase(test_object)

				if nose_argv:
					test_argv = nose_argv
				else:
					test_argv = [
						test_module.__name__.lower(), 
						"-d", 
						"-s", 
						"--verbosity=2", 
						"--with-xunit", 
						"--xunit-file=%s.xml" % test_object.__name__.lower()
					]
				
				nose.run(argv = test_argv, suite = test_suite)

		del  test_module
开发者ID:ahalester,项目名称:casa-testing,代码行数:27,代码来源:helper.py


示例14: callNose

        def callNose( self, args ):
            # run once to get splits
            collectOnlyArgs = args[:]
            collectOnlyArgs.extend([ '-q', '--collect-only', '--with-id' ])
            retval = nose.run(argv=collectOnlyArgs, addplugins=[DetailedOutputter()])           
            if not retval:
                print "Failed to collect TestCase IDs"
                return retval

            idhandle = open( ".noseids", "r" )
            testIds = pickle.load(idhandle)['ids']
            idhandle.close()

            totalCases = len(testIds)
            myIds      = []
            for id in sorted( testIds.keys() ):
                if ( id % int(self.testTotalSlices) ) == int(self.testCurrentSlice):
                    myIds.append( str(id) )

            print "Out of %s cases, we will run %s" % (totalCases, len(myIds))
            if not myIds:
                return True
            
            args.extend(['-v', '--with-id'])
            args.extend(myIds)
            return nose.run( argv=args )
开发者ID:PerilousApricot,项目名称:WMCore-OLDOLD,代码行数:26,代码来源:setup_test.py


示例15: run_nose

def run_nose(verbose=False, run_answer_tests=False, answer_big_data=False,
             call_pdb = False):
    import nose, os, sys, yt
    from yt.funcs import mylog
    orig_level = mylog.getEffectiveLevel()
    mylog.setLevel(50)
    nose_argv = sys.argv
    nose_argv += ['--exclude=answer_testing','--detailed-errors', '--exe']
    if call_pdb:
        nose_argv += ["--pdb", "--pdb-failures"]
    if verbose:
        nose_argv.append('-v')
    if run_answer_tests:
        nose_argv.append('--with-answer-testing')
    if answer_big_data:
        nose_argv.append('--answer-big-data')
    initial_dir = os.getcwd()
    yt_file = os.path.abspath(yt.__file__)
    yt_dir = os.path.dirname(yt_file)
    os.chdir(yt_dir)
    try:
        nose.run(argv=nose_argv)
    finally:
        os.chdir(initial_dir)
        mylog.setLevel(orig_level)
开发者ID:danielgrassinger,项目名称:yt_new_frontend,代码行数:25,代码来源:testing.py


示例16: run

    def run(self):
        import nose
        from nose.plugins.manager import DefaultPluginManager

        excludes = [r"^examples$", r"^deprecated$"]
        config = nose.config.Config(exclude=map(re.compile, excludes), plugins=DefaultPluginManager(), env=os.environ)
        nose.run(defaultTest="pysb", config=config, argv=["", "--with-doctest"])
开发者ID:Talqa,项目名称:pysb,代码行数:7,代码来源:setup.py


示例17: command

 def command(self, *args, **options):
     try:
         cover = args[0]
         cover = cover.lower() == "true"
     except IndexError:
         cover = False
     if cover:
         #Grab the pythonpath argument and look for tests there
         app_names = settings.INSTALLED_APPS
         #Grab the top level app name from installed_apps
         app_labels = list(set([a.split('.')[0] for a in app_names]))
         app_paths = []
         #We want to figure out coverage for the "lower-level" apps, so import all the top level apps
         #and get their paths
         for al in app_labels:
             mod = import_module(al)
             app_paths.append(os.path.dirname(mod.__file__))
         #Pass paths to pkgutil to get the names of the submodules
         sub_labels = [name for _, name, _ in pkgutil.iter_modules(app_paths) if name not in settings.DO_NOT_COVER]
         #Produce a coverage report for installed_apps
         argv = ['{0}'.format(options['pythonpath']), '--with-coverage', '--cover-package={0}'.format(','.join(app_labels + sub_labels))]
         nose.run(argv=argv)
     else:
         argv = ['{0}'.format(options['pythonpath'])]
         nose.run(argv=argv)
开发者ID:VikParuchuri,项目名称:percept,代码行数:25,代码来源:test.py


示例18: coverage

def coverage():
    """
    Create console and HTML coverage reports for the full test suite.
    """
    import nose
    from coverage import coverage

    from jig.tests.noseplugin import TestSetup

    omit = [
        '*noseplugin*',
        '*entrypoints*',
        '*testcase*',
        '*packages*',
        '*backports.py',
        '*jig/__init__.py']

    cov = coverage(
        branch=True, config_file=False, source=['jig'],
        omit=omit)

    cov.start()

    nose.run(argv=['nose', '-w', 'src'] + sys.argv[1:],
             addplugins=[TestSetup()])

    cov.stop()

    cov.report()
    cov.html_report(directory='../cover')
开发者ID:dmore,项目名称:jig,代码行数:30,代码来源:entrypoints.py


示例19: run

def run(*arg, **kw):
    """
    Specialized version of nose.run for use inside of doctests that
    test test runs.

    This version of run() prints the result output to stdout.  Before
    printing, the output is processed by replacing the timing
    information with an ellipsis (...), removing traceback stacks, and
    removing trailing whitespace.

    Use this version of run wherever you are writing a doctest that
    tests nose (or unittest) test result output.

    Note: do not use doctest: +ELLIPSIS when testing nose output,
    since ellipses ("test_foo ... ok") in your expected test runner
    output may match multiple lines of output, causing spurious test
    passes!
    """
    from nose import run
    from nose.config import Config
    from nose.plugins.manager import PluginManager

    buffer = StringIO()
    if 'config' not in kw:
        plugins = kw.pop('plugins', None)
        env = kw.pop('env', {})
        kw['config'] = Config(env=env, plugins=PluginManager(plugins=plugins))
    if 'argv' not in kw:
        kw['argv'] = ['nosetests', '-v']
    kw['config'].stream = buffer
    run(*arg, **kw)
    out = buffer.getvalue()
    print munge_nose_output_for_doctest(out)
开发者ID:scbarber,项目名称:horriblepoems,代码行数:33,代码来源:plugintest.py


示例20: main

def main(args):
    for js in JOB_STORAGES:
        print "Working on backend: " + js
        post_request("{}/config".format(ADDRESS), {'JOBS_STORAGE': js})
        post_request("{}/config/resetDB".format(ADDRESS))
        noseargs = ['testStorages', '-v', '--ignore-files=.*testConfig.*', '--with-xunit', '--xunit-file=%s_Results.xml' %js]
        nose.run(argv=noseargs)
开发者ID:kkonrad,项目名称:troia-python-client,代码行数:7,代码来源:runTestsOnStorages.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python nose.run_exit函数代码示例发布时间:2022-05-27
下一篇:
Python nose.main函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap