本文整理汇总了Python中nose.core.run函数的典型用法代码示例。如果您正苦于以下问题:Python run函数的具体用法?Python run怎么用?Python run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: unit_test
def unit_test(extra_args=[]):
"""
run unit tests for this code base. Pass any arguments that nose accepts.
"""
path = os.path.realpath(os.path.join(os.getcwd(), 'tests/unit'))
args = [
path, '-x', '-v', '--with-coverage', '--cover-erase',
'--cover-package=./customs'
]
if extra_args:
args.extend(extra_args)
if run(argv=args):
return 0
else:
return 1
开发者ID:TuneOSS,项目名称:customs,代码行数:17,代码来源:build.py
示例17: run_tests
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 = QuantumTestRunner(stream=c.stream, verbosity=c.verbosity, config=c)
return not core.run(config=c, testRunner=runner)
开发者ID:kumarcv,项目名称:openstack-nf,代码行数:18,代码来源:test_lib.py
示例18: main
def main():
description = "Runs slack unit and/or integration tests."
parser = argparse.ArgumentParser(description=description)
parser.add_argument('-t', '--service-tests', action='append', default=[],
help="Run tests for a given service. This will "
"run any test tagged with the specified value, "
"e.g -t s3 -t chat")
known_args, remaining_args = parser.parse_known_args()
attribute_args = []
for service_attribute in known_args.service_tests:
attribute_args.extend(['-a', '!notdefault,' +service_attribute])
if not attribute_args:
attribute_args = ['-a', '!notdefault']
all_args = [__file__] + attribute_args + remaining_args
print "nose command: {0}".format(' '.join(all_args))
if run(argv=all_args):
return 0
else:
return 1
开发者ID:BWStearns,项目名称:slack,代码行数:19,代码来源:test.py
示例19: test
def test(self, verbose=False):
"""Performs the actual running of the tests.
Parameters
----------
verbose : bool
flag for running in verbose mode.
Returns
-------
bool
test run success status
"""
# NOTE: it doesn't seem to matter what the first element of the argv
# list is, there just needs to be something there.
argv = [self._filename, '-I DO_NOT_IGNORE_ANYTHING']
if PY3:
argv.extend(['--with-doctest', '--doctest-tests'])
if verbose:
argv.append('-v')
return core.run(argv=argv, defaultTest=self._test_dir)
开发者ID:terrycojones,项目名称:scikit-bio,代码行数:21,代码来源:_testing.py
示例20: main
def main(whitelist=[]):
description = ("Runs boto unit and/or integration tests. "
"Arguments will be passed on to nosetests. "
"See nosetests --help for more information.")
parser = argparse.ArgumentParser(description=description)
parser.add_argument('-t', '--service-tests', action="append", default=[],
help="Run tests for a given service. This will "
"run any test tagged with the specified value, "
"e.g -t s3 -t ec2")
known_args, remaining_args = parser.parse_known_args()
attribute_args = []
for service_attribute in known_args.service_tests:
attribute_args.extend(['-a', '!notdefault,' +service_attribute])
if not attribute_args:
# If the user did not specify any filtering criteria, we at least
# will filter out any test tagged 'notdefault'.
attribute_args = ['-a', '!notdefault']
# Set default tests used by e.g. tox. For Py2 this means all unit
# tests, while for Py3 it's just whitelisted ones.
if 'default' in remaining_args:
# Run from the base project directory
os.chdir(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
for i, arg in enumerate(remaining_args):
if arg == 'default':
if sys.version_info[0] == 3:
del remaining_args[i]
remaining_args += PY3_WHITELIST
else:
remaining_args[i] = 'tests/unit'
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:merckhung,项目名称:libui,代码行数:40,代码来源:test.py
注:本文中的nose.core.run函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论