本文整理汇总了Python中nose.runmodule函数的典型用法代码示例。如果您正苦于以下问题:Python runmodule函数的具体用法?Python runmodule怎么用?Python runmodule使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了runmodule函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: main
def main(argv=sys.argv[1:]):
parser = argparse.ArgumentParser()
parser.add_argument(
'-v', '--verbose',
action='store_true',
help="Logging is normally set to an INFO level. When this flag "
"is used logging is set to DEBUG. ")
args = parser.parse_args(argv)
# Configure logging
logging_level = logging.DEBUG if args.verbose is True else logging.INFO
logging.basicConfig()
logging.getLogger().setLevel(logging_level)
xunit_file = os.path.join(os.environ.get('RIFT_MODULE_TEST'),
"restconf_systest.xml")
nose.runmodule(
argv=[sys.argv[0],
"--logging-level={}".format(logging.getLevelName(logging_level)),
"--logging-format={}".format(
'%(asctime)-15s %(levelname)s %(message)s'),
"--nocapture", # display stdout immediately
"--with-xunit",
"--xunit-file=%s" % xunit_file])
开发者ID:RIFTIO,项目名称:RIFT.ware,代码行数:26,代码来源:restconf_systest.py
示例2: main
def main():
"""The main routine."""
# Parse arguments
local_url = 'http://localhost:{}'.format(LOCAL_TEST_PORT)
parser = argparse.ArgumentParser(description='Run web-service tests')
parser.add_argument(
'-e', '--endpoint', dest='endpoint', default='auto',
help='Which server to test against.\n'
'auto: {} (server starts automatically)\n'
'local: http://localhost:8080\n'
'prod: https://url-caster.appspot.com\n'
'dev: https://url-caster-dev.appspot.com\n'
'*: Other values interpreted literally'
.format(local_url))
parser.add_argument('-x', '--experimental', dest='experimental', action='store_true', default=False)
args = parser.parse_args()
# Setup the endpoint
endpoint = args.endpoint
server = None
if endpoint.lower() == 'auto':
endpoint = local_url
print 'Starting local server1...',
server = subprocess.Popen([
'/usr/bin/python /home/happy/google_appengine/dev_appserver.py', os.path.dirname(__file__),
'--port', str(LOCAL_TEST_PORT),
'--admin_port', str(LOCAL_TEST_PORT + 1),
], bufsize=1, stderr=subprocess.PIPE, preexec_fn=os.setsid)
# Wait for the server to start up
while True:
line = server.stderr.readline()
if 'Unable to bind' in line:
print 'Rogue server already running.'
return 1
if 'running at: {}'.format(local_url) in line:
break
print 'done'
elif endpoint.lower() == 'local':
endpoint = 'http://localhost:8080'
elif endpoint.lower() == 'prod':
endpoint = 'https://url-caster.appspot.com'
elif endpoint.lower() == 'dev':
endpoint = 'https://url-caster-dev.appspot.com'
PwsTest.HOST = endpoint
PwsTest.ENABLE_EXPERIMENTAL = args.experimental
# Run the tests
try:
nose.runmodule()
finally:
# Teardown the endpoint
if server:
os.killpg(os.getpgid(server.pid), signal.SIGINT)
server.wait()
# We should never get here since nose.runmodule will call exit
return 0
开发者ID:HappyBearZzz,项目名称:web-service,代码行数:57,代码来源:tests.py
示例3: main
def main():
"""The main routine."""
# Parse arguments
local_url = 'http://localhost:{}'.format(LOCAL_TEST_PORT)
parser = argparse.ArgumentParser(description='Run web-service tests')
parser.add_argument(
'-e', '--endpoint', dest='endpoint', default='AUTO',
help='Which server to test against.\n'
'AUTO: {} (server starts automatically)\n'
'LOCAL: http://localhost:8080\n'
'PROD: http://url-caster.appspot.com\n'
'DEV: http://url-caster-dev.appspot.com\n'
'*: Other values interpreted literally'
.format(local_url))
args = parser.parse_args()
# Setup the endpoint
endpoint = args.endpoint
server = None
if endpoint == 'AUTO':
endpoint = local_url
print 'Starting local server...',
server = subprocess.Popen([
'dev_appserver.py', os.path.dirname(__file__),
'--port', str(LOCAL_TEST_PORT),
'--admin_port', str(LOCAL_TEST_PORT + 1),
], bufsize=1, stderr=subprocess.PIPE, preexec_fn=os.setsid)
# Wait for the server to start up
while True:
line = server.stderr.readline()
if 'Unable to bind' in line:
print 'Rogue server already running.'
return 1
if 'running at: {}'.format(local_url) in line:
break
print 'done'
elif endpoint == 'LOCAL':
endpoint = 'http://localhost:8080'
elif endpoint == 'PROD':
endpoint = 'http://url-caster.appspot.com'
elif endpoint == 'DEV':
endpoint = 'http://url-caster-dev.appspot.com'
PwsTest.HOST = endpoint
# Run the tests
try:
nose.runmodule()
finally:
# Teardown the endpoint
if server:
os.killpg(os.getpgid(server.pid), signal.SIGINT)
server.wait()
# We should never get here since nose.runmodule will call exit
return 0
开发者ID:lemos-beta,项目名称:physical-web,代码行数:55,代码来源:tests.py
示例4: run_module
def run_module(name, file):
"""Run current test cases of the file.
Args:
name: __name__ attribute of the file.
file: __file__ attribute of the file.
"""
if name == '__main__':
nose.runmodule(argv=[file, '-vvs', '-x', '--pdb', '--pdb-failure'],
exit=False)
开发者ID:2php,项目名称:chainer,代码行数:12,代码来源:__init__.py
示例5: _run_tests
def _run_tests(path):
"""Runs tests on a library located at path"""
global rx_h5, nucs, npert, G
rx_h5 = tb.openFile(path, 'r')
nucs = rx_h5.root.transmute_nucs_LL[:]
npert = len(rx_h5.root.perturbations)
G = len(rx_h5.root.energy[0]) - 1
nose.runmodule(__name__, argv=[__file__])
rx_h5.close()
开发者ID:bartonfriedland,项目名称:bright,代码行数:12,代码来源:testing.py
示例6: main
def main():
'''Run test'''
# Get line
argv = list(sys.argv)
# Add configuration
argv.extend([
'--verbosity=2',
'--exe',
'--nocapture',
'--with-nosango',
])
# Run test
nose.runmodule(argv=argv)
开发者ID:equeny,项目名称:django-oauth2,代码行数:13,代码来源:__init__.py
示例7: runmodule
def runmodule(level=logging.INFO, verbosity=1, argv=[]):
"""
:param argv: optional list of string with additional options passed to nose.run
see http://nose.readthedocs.org/en/latest/usage.html
"""
if argv is None:
return nose.runmodule()
setlog(level)
""" ensures stdout is printed after the tests results"""
import sys
from io import StringIO
module_name = sys.modules["__main__"].__file__
old_stdout = sys.stdout
sys.stdout = mystdout = StringIO()
result = nose.run(
argv=[
sys.argv[0],
module_name,
'-s','--nologcapture',
'--verbosity=%d'%verbosity,
]+argv
)
sys.stdout = old_stdout
print(mystdout.getvalue())
开发者ID:goulu,项目名称:Goulib,代码行数:29,代码来源:tests.py
示例8: test
def test(**kwargs):
""" Run all pylada nose tests
Does not include some C++ only tests, nor tests that require
external programs such as vasp. Those should be run via ctest.
"""
from os.path import dirname
from nose import runmodule
return runmodule(dirname(__file__), **kwargs)
开发者ID:hbwzhsh,项目名称:pylada-light,代码行数:9,代码来源:__init__.in.py
示例9: main
def main():
"""Main routine, executed when this file is run as a script """
# Create a tempdir, as a subdirectory of the current one, which all tests
# use for their storage. By default, it is removed at the end.
global TESTDIR
cwd = os.getcwd()
TESTDIR = tempfile.mkdtemp(prefix='tmp-testdata-',dir=cwd)
print "Running tests:"
# This call form is ipython-friendly
try:
os.chdir(TESTDIR)
nose.runmodule(argv=[__file__,'-vvs'],
exit=False)
finally:
os.chdir(cwd)
print
print "Cleanup - removing temp directory:", TESTDIR
# If you need to debug a problem, comment out the next line that cleans
# up the temp directory, and you can see in there all temporary files
# created by the test code
shutil.rmtree(TESTDIR)
print """
***************************************************************************
TESTS FINISHED
***************************************************************************
If the printout above did not finish in 'OK' but instead says 'FAILED', copy
and send the *entire* output, including the system information below, for help.
We'll do our best to assist you. You can send your message to the Scipy user
mailing list:
http://mail.scipy.org/mailman/listinfo/scipy-user
but feel free to also CC directly: [email protected]
"""
sys_info()
开发者ID:cburns,项目名称:scipytut,代码行数:40,代码来源:adv_tut_checklist.py
示例10: main
def main(args=None):
""" run tests for module
"""
options = parse_test_args(args)
if options.nonose or options.test:
# Run tests outside of nose.
module = sys.modules['__main__']
functions = inspect.getmembers(module, inspect.isfunction)
if options.test:
func = module.__dict__.get('_test_' + options.test)
if func is None:
print 'No test named _test_%s' % options.test
print 'Known tests are:', [name[6:] for name, func in functions
if name.startswith('_test_')]
sys.exit(1)
tests = [func]
else:
# Run all tests.
tests = [func for name, func in functions
if name.startswith('_test_')]
TEST_CONFIG['modname'] = '__main__'
setup_server(virtual_display=False)
browser = SafeDriver(setup_chrome())
try:
for test in tests:
try:
test(browser)
except SkipTest:
pass
finally:
if not options.noclose:
try:
browser.quit()
except WindowsError:
# if it already died, calling kill on a defunct process
# raises a WindowsError: Access Denied
pass
teardown_server()
else:
# Run under nose.
import nose
sys.argv.append('--cover-package=openmdao.')
sys.argv.append('--cover-erase')
sys.exit(nose.runmodule())
开发者ID:andrewning,项目名称:OpenMDAO-Framework,代码行数:46,代码来源:util.py
示例11: main
def main(args=None):
""" run tests for module
"""
options = parse_test_args(args)
if options.nonose or options.test:
# Run tests outside of nose.
module = sys.modules['__main__']
functions = inspect.getmembers(module, inspect.isfunction)
if options.test:
func = module.__dict__.get('_test_' + options.test)
if func is None:
print 'No test named _test_%s' % options.test
print 'Known tests are:', [name[6:] for name, func in functions
if name.startswith('_test_')]
sys.exit(1)
tests = [func]
else:
# Run all tests.
tests = [func for name, func in functions
if name.startswith('_test_')]
setup_server(virtual_display=False)
browser = SafeDriver(setup_chrome())
try:
for test in tests:
test(browser)
finally:
if not options.noclose:
browser.quit()
teardown_server()
else:
# Run under nose.
import nose
sys.argv.append('--cover-package=openmdao.')
sys.argv.append('--cover-erase')
sys.exit(nose.runmodule())
开发者ID:Kenneth-T-Moore,项目名称:OpenMDAO-Framework,代码行数:37,代码来源:util.py
示例12: DatetimeIndex
self.assertTrue(idx.equals(DatetimeIndex(dates, tz="US/Eastern")))
idx = idx.tz_convert("UTC")
self.assertTrue(idx.equals(DatetimeIndex(dates, tz="UTC")))
dates = ["2010-12-01 00:00", "2010-12-02 00:00", NaT]
idx = DatetimeIndex(dates)
idx = idx.tz_localize("US/Pacific")
self.assertTrue(idx.equals(DatetimeIndex(dates, tz="US/Pacific")))
idx = idx.tz_convert("US/Eastern")
expected = ["2010-12-01 03:00", "2010-12-02 03:00", NaT]
self.assertTrue(idx.equals(DatetimeIndex(expected, tz="US/Eastern")))
idx = idx + offsets.Hour(5)
expected = ["2010-12-01 08:00", "2010-12-02 08:00", NaT]
self.assertTrue(idx.equals(DatetimeIndex(expected, tz="US/Eastern")))
idx = idx.tz_convert("US/Pacific")
expected = ["2010-12-01 05:00", "2010-12-02 05:00", NaT]
self.assertTrue(idx.equals(DatetimeIndex(expected, tz="US/Pacific")))
idx = idx + np.timedelta64(3, "h")
expected = ["2010-12-01 08:00", "2010-12-02 08:00", NaT]
self.assertTrue(idx.equals(DatetimeIndex(expected, tz="US/Pacific")))
idx = idx.tz_convert("US/Eastern")
expected = ["2010-12-01 11:00", "2010-12-02 11:00", NaT]
self.assertTrue(idx.equals(DatetimeIndex(expected, tz="US/Eastern")))
if __name__ == "__main__":
nose.runmodule(argv=[__file__, "-vvs", "-x", "--pdb", "--pdb-failure"], exit=False)
开发者ID:arvindchari88,项目名称:newGitTest,代码行数:30,代码来源:test_timezones.py
示例13: pml_hybrid
out = pml_hybrid(synthetic_data(), theta=(0., 1.))
assert_equals(out.shape, (4, 5, 5))
assert_equals(np.isnan(out).sum(), 0)
def test_pml_quad():
out = pml_quad(synthetic_data(), theta=(0., 1.))
assert_equals(out.shape, (4, 5, 5))
assert_equals(np.isnan(out).sum(), 0)
def test_sirt():
out = sirt(synthetic_data(), theta=(0., 1.))
assert_equals(out.shape, (4, 5, 5))
assert_equals(np.isnan(out).sum(), 0)
def test_write_center():
dpath = os.path.join('test', 'tmp')
write_center(synthetic_data(), [0., 1.], dpath, center=[3, 5, 0.5])
assert_equals(os.path.isfile(os.path.join(dpath, '3.00.tiff')), True)
assert_equals(os.path.isfile(os.path.join(dpath, '3.50.tiff')), True)
assert_equals(os.path.isfile(os.path.join(dpath, '4.00.tiff')), True)
assert_equals(os.path.isfile(os.path.join(dpath, '4.50.tiff')), True)
shutil.rmtree(dpath)
if __name__ == '__main__':
import nose
nose.runmodule(exit=False)
开发者ID:smmiller196,项目名称:tomopy,代码行数:30,代码来源:test_recon.py
示例14: list
# check calling w/ named arguments
shape_args = list(shape_args)
vals = [meth(x, *shape_args) for meth in meths]
npt.assert_(np.all(np.isfinite(vals)))
names, a, k = shape_argnames[:], shape_args[:], {}
while names:
k.update({names.pop(): a.pop()})
v = [meth(x, *a, **k) for meth in meths]
npt.assert_array_equal(vals, v)
if not 'n' in k.keys():
# `n` is first parameter of moment(), so can't be used as named arg
npt.assert_equal(distfn.moment(3, *a, **k),
distfn.moment(3, *shape_args))
# unknown arguments should not go through:
k.update({'kaboom': 42})
npt.assert_raises(TypeError, distfn.cdf, x, **k)
def check_scale_docstring(distfn):
if distfn.__doc__ is not None:
# Docstrings can be stripped if interpreter is run with -OO
npt.assert_('scale' not in distfn.__doc__)
if __name__ == "__main__":
# nose.run(argv=['', __file__])
nose.runmodule(argv=[__file__,'-s'], exit=False)
开发者ID:Jianwei-Wang,项目名称:python2.7_lib,代码行数:30,代码来源:test_discrete_basic.py
示例15: test_endog_only_raise
def test_endog_only_raise(self):
np.testing.assert_raises(Exception, sm_data.handle_data,
(self.y, None, 'raise'))
def test_endog_only_drop(self):
y = self.y
y = y.dropna()
data = sm_data.handle_data(self.y, None, 'drop')
np.testing.assert_array_equal(data.endog, y.values)
def test_mv_endog(self):
y = self.X
y = y.ix[~np.isnan(y.values).any(axis=1)]
data = sm_data.handle_data(self.X, None, 'drop')
np.testing.assert_array_equal(data.endog, y.values)
def test_labels(self):
2, 10, 14
labels = pandas.Index([0, 1, 3, 4, 5, 6, 7, 8, 9, 11, 12, 13, 15,
16, 17, 18, 19, 20, 21, 22, 23, 24])
data = sm_data.handle_data(self.y, self.X, 'drop')
np.testing.assert_(data.row_labels.equals(labels))
if __name__ == "__main__":
import nose
#nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
# exit=False)
nose.runmodule(argv=[__file__, '-vvs', '-x'], exit=False)
开发者ID:dengemann,项目名称:statsmodels,代码行数:30,代码来源:test_data.py
示例16: test_get_call_data
self.assertTrue(len(dates) > 6)
def test_get_call_data(self):
with tm.assertRaises(NotImplementedError):
self.goog.get_call_data()
def test_get_put_data(self):
with tm.assertRaises(NotImplementedError):
self.goog.get_put_data()
def test_get_near_stock_price(self):
with tm.assertRaises(NotImplementedError):
self.goog.get_near_stock_price()
def test_get_forward_data(self):
with tm.assertRaises(NotImplementedError):
self.goog.get_forward_data([1, 2, 3])
def test_get_all_data(self):
with tm.assertRaises(NotImplementedError):
self.goog.get_all_data()
def test_get_options_data_with_year(self):
with tm.assertRaises(NotImplementedError):
self.goog.get_options_data(year=2016)
if __name__ == '__main__':
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
exit=False) # pragma: no cover
开发者ID:jtkiley,项目名称:pandas-datareader,代码行数:30,代码来源:test_google_options.py
示例17: TestNoNewAttributesMixin
np.transpose, obj, axes=1)
class TestNoNewAttributesMixin(tm.TestCase):
def test_mixin(self):
class T(NoNewAttributesMixin):
pass
t = T()
self.assertFalse(hasattr(t, "__frozen"))
t.a = "test"
self.assertEqual(t.a, "test")
t._freeze()
# self.assertTrue("__frozen" not in dir(t))
self.assertIs(getattr(t, "__frozen"), True)
def f():
t.b = "test"
self.assertRaises(AttributeError, f)
self.assertFalse(hasattr(t, "b"))
if __name__ == '__main__':
import nose
nose.runmodule(argv=[__file__, '-vvs', '-x', '--pdb', '--pdb-failure'],
# '--with-coverage', '--cover-package=pandas.core'],
exit=False)
开发者ID:nateGeorge,项目名称:pandas,代码行数:30,代码来源:test_base.py
示例18: test_logp
return 0.
E.value = 2
def test_logp(self):
self.B.rand()
lp1 = utils.logp_of_set(set([self.A,self.B,self.D]))
assert_equal(lp1, self.A.logp+self.B.logp+self.D.logp)
def test_ZeroProb(self):
self.B.value = -1
for i in xrange(1000):
try:
utils.logp_of_set(set([self.A,self.B,self.D, self.E]))
except:
cls, inst, tb = sys.exc_info()
assert(cls is ZeroProbability)
def test_other_err(self):
self.B.rand()
for i in xrange(1000):
try:
utils.logp_of_set(set([self.A,self.B,self.D,self.E]))
except:
cls, inst, tb = sys.exc_info()
assert(cls is RuntimeError)
if __name__ == '__main__':
C =nose.config.Config(verbosity=1)
nose.runmodule(config=C)
开发者ID:huard,项目名称:pymc,代码行数:30,代码来源:test_utils.py
示例19: assert_
pdf_r = np.array([3.941955996757291e-04, 1.568067236862745e-03,
6.136996029432048e-03, 3.183098861837907e-01,
3.167418189469279e-01, 1.269297588738406e-01])
pdf_st = skewt.pdf(x, 1, 10) #args = (df, alpha) = (1, 10))
assert_(np.allclose(pdf_st, pdf_r, rtol=1e-13, atol=1e-25))
#noquote(sprintf("%.15e,", pst(c(-2,-1, -0.5,0,1,2), shape=10, df=1)))
cdf_r = np.array([7.893671370544414e-04, 1.575817262600422e-03,
3.128720749105560e-03, 3.172551743055351e-02,
5.015758172626005e-01, 7.056221318361879e-01])
cdf_st = skewt.cdf(x, 1, 10) #args = (df, alpha) = (1, 10)
assert_(np.allclose(cdf_st, cdf_r, rtol=1e-13, atol=1e-25))
if __name__ == '__main__':
import nose
nose.runmodule(argv=['__main__','-vvs','-x','--pdb', '--pdb-failure'],
exit=False)
print ('Done')
'''
>>> skewt.pdf([-2,-1,0,1,2], 10000000, 10)
array([ 2.98557345e-90, 3.68850289e-24, 3.98942271e-01,
4.83941426e-01, 1.07981952e-01])
>>> skewt.pdf([-2,-1,0,1,2], np.inf, 10)
array([ nan, nan, nan, nan, nan])
'''
开发者ID:bolliger32,项目名称:pygwr,代码行数:30,代码来源:test_extras.py
示例20: NdIndexableMapping
ndmap = NdIndexableMapping(data, dimensions=[self.dim1, self.dim2])
reduced_dims = ['intdim']
reduced_ndmap = ndmap.reindex(reduced_dims)
self.assertEqual(reduced_ndmap.dimension_labels, reduced_dims)
def test_idxmapping_adddimension(self):
ndmap = NdIndexableMapping(self.init_items_1D_list, dimensions=[self.dim1])
ndmap2d = ndmap.add_dimension(self.dim2, 0, 0.5)
self.assertEqual(ndmap2d.keys(), [(0.5, 1), (0.5, 5)])
self.assertEqual(ndmap2d.dimensions, [self.dim2, self.dim1])
def test_idxmapping_clone(self):
ndmap = NdIndexableMapping(self.init_items_1D_list, dimensions=[self.dim1])
cloned_ndmap = ndmap.clone(data_type=str)
self.assertEqual(cloned_ndmap.data_type, str)
def test_idxmapping_apply_key_type(self):
data = dict([(0.5, 'a'), (1.5, 'b')])
ndmap = NdIndexableMapping(data, dimensions=[self.dim1])
self.assertEqual(ndmap.keys(), [0, 1])
if __name__ == "__main__":
import nose
nose.runmodule(argv=[sys.argv[0], "--logging-level", "ERROR"])
开发者ID:ceball,项目名称:imagen,代码行数:30,代码来源:testndmapping.py
注:本文中的nose.runmodule函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论