本文整理汇总了Python中nose.run函数的典型用法代码示例。如果您正苦于以下问题:Python run函数的具体用法?Python run怎么用?Python run使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了run函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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)
示例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
示例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)
示例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("")
示例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()
示例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)
示例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)
示例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)
示例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")
示例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))
示例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"]
)
示例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
示例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 )
示例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)