本文整理汇总了Python中unittest.defaultTestLoader.loadTestsFromName函数的典型用法代码示例。如果您正苦于以下问题:Python loadTestsFromName函数的具体用法?Python loadTestsFromName怎么用?Python loadTestsFromName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了loadTestsFromName函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
def run(self):
import lzw
doctest.testmod(lzw)
utests = defaultTestLoader.loadTestsFromName(TEST_MODULE_NAME)
urunner = TextTestRunner(verbosity=2)
urunner.run(utests)
if self.runslow:
utests = defaultTestLoader.loadTestsFromName(SLOW_TEST_MODULE_NAME)
urunner = TextTestRunner(verbosity=2)
urunner.run(utests)
示例2: run
def run(self):
import lzw
success = doctest.testmod(lzw).failed == 0
utests = defaultTestLoader.loadTestsFromName(TEST_MODULE_NAME)
urunner = TextTestRunner(verbosity=2)
success &= urunner.run(utests).wasSuccessful()
if self.runslow:
utests = defaultTestLoader.loadTestsFromName(SLOW_TEST_MODULE_NAME)
urunner = TextTestRunner(verbosity=2)
success &= urunner.run(utests).wasSuccessful()
if not success:
raise distutils.errors.DistutilsError('Test failure')
示例3: run_tests
def run_tests(options, args):
arg = args[0]
module_name = arg
if module_name.endswith(".py"):
module_name = module_name[:-3]
class _runner(object):
def __new__(cls, *args, **kawrgs):
return DatabaseTestRunner(
database_path=options.db, runid=options.runid, module_name=module_name, verbosity=options.verbosity
)
if options.db:
try:
from unittest import runner
except ImportError:
pass
else:
runner.TextTestRunner = _runner
import unittest
unittest.TextTestRunner = _runner
import test_support
test_support.BasicTestRunner = _runner
sys.argv = args
if os.path.exists(arg):
execfile_as_main(arg)
else:
test = defaultTestLoader.loadTestsFromName(arg)
result = _runner().run(test)
sys.exit(not result.wasSuccessful())
示例4: run_tests
def run_tests(options, args):
arg = args[0]
module_name = arg
if module_name.endswith('.py'):
module_name = module_name[:-3]
class _runner(object):
def __new__(cls, *args, **kawrgs):
return DatabaseTestRunner(database_path=options.db, runid=options.runid, module_name=module_name, verbosity=options.verbosity)
if options.db:
import unittest
unittest.TextTestRunner = _runner
import test_support
test_support.BasicTestRunner = _runner
sys.argv = args
globals()['__file__'] = arg
if os.path.exists(arg):
execfile(arg, globals())
else:
test = defaultTestLoader.loadTestsFromName(arg)
result = _runner().run(test)
sys.exit(not result.wasSuccessful())
示例5: run_tests
def run_tests(options, args):
if len(args) != 1:
sys.exit('--record requires exactly one test module to run')
arg = args[0]
module_name = arg
if module_name.endswith('.py'):
module_name = module_name[:-3]
class _runner(object):
def __new__(cls, *args, **kawrgs):
return DatabaseTestRunner(database_path=options.db, runid=options.runid, module_name=module_name, verbosity=options.verbosity)
if options.db:
import unittest
unittest.TextTestRunner = _runner
import test_support
test_support.BasicTestRunner = _runner
if os.path.exists(arg):
sys.argv = args
saved_globals = {'__file__': __file__}
try:
globals()['__file__'] = arg
# QQQ this makes tests reported as if they are from __main__ and screws up warnings location
execfile(arg, globals())
finally:
globals().update(saved_globals)
else:
test = defaultTestLoader.loadTestsFromName(arg)
result = _runner().run(test)
sys.exit(not result.wasSuccessful())
示例6: suite
def suite():
suite = doctest.DocFileSuite(
'test_loader.py',
'test_views.py')
suite.addTest(defaultTestLoader.loadTestsFromName(
'yui_loader.tests.test_middleware'))
return suite
示例7: suite
def suite():
"""Unit test suite; run by testing 'repository.tests.suite'"""
from unittest import defaultTestLoader, TestSuite
return TestSuite(
[defaultTestLoader.loadTestsFromName(__name__+'.'+test_name)
for test_name in __all__]
)
示例8: test_suite
def test_suite():
suite = defaultTestLoader.loadTestsFromName(__name__)
suite.addTest(
ztc.FunctionalDocFileSuite(
'browser.txt', package='collective.usernamelogger',
test_class=FunctionalTestCase, optionflags=optionflags)
)
return suite
示例9: run_tests
def run_tests(self):
from unittest import TextTestRunner, defaultTestLoader as loader
result = TextTestRunner().run(
loader.loadTestsFromName(
'tests.{0}'.format(self.test_suite).strip('. ')
)
)
return exit(0) if not (result.failures + result.errors) else exit(1)
示例10: make_suite
def make_suite(prefix='', extra=()):
tests = TESTS + extra
test_names = list(prefix + x for x in tests)
suite = TestSuite()
suite.addTest(defaultTestLoader.loadTestsFromNames(test_names))
for name in OPTIONAL_TESTS:
test_name = prefix + name
try:
suite.addTest(defaultTestLoader.loadTestsFromName(test_name))
except (ImportError, AttributeError):
sys.stderr.write("### Disabled test '%s', dependency not found\n" % name)
return suite
示例11: make_suite
def make_suite(prefix='', extra=(), force_all=False):
tests = TESTS + extra
test_names = list(prefix + x for x in tests)
suite = TestSuite()
suite.addTest(defaultTestLoader.loadTestsFromNames(test_names))
for name in OPTIONAL_TESTS:
test_name = prefix + name
try:
suite.addTest(defaultTestLoader.loadTestsFromName(test_name))
except (ImportError, AttributeError):
if force_all:
# If force_all, don't let us skip tests
raise ImportError('Could not load test module %s and force_all is enabled.' % test_name)
sys.stderr.write("### Disabled test '%s', dependency not found\n" % name)
return suite
示例12: worker_main
def worker_main():
global DB
if killpg:
try:
os.setpgrp()
except AttributeError:
pass
path = sys.argv[1]
verbosity = int(os.environ['testrunner_verbosity'])
test_id = int(os.environ['testrunner_test_id'])
run_id = os.environ['testrunner_run_id']
db_name = os.environ.get('testrunner_db')
if db_name:
DB = sqlite3.connect(db_name)
DEFAULT_PARAMS['testcase'] = {'run_id': run_id,
'test_id': test_id}
class _runner(object):
def __new__(cls, *args, **kawrgs):
return DatabaseTestRunner(verbosity=verbosity)
if DB:
try:
from unittest import runner
except ImportError:
pass
else:
runner.TextTestRunner = _runner
import unittest
unittest.TextTestRunner = _runner
import test_support
test_support.BasicTestRunner = _runner
sys.argv = sys.argv[1:]
if os.path.exists(path):
execfile_as_main(path)
else:
test = defaultTestLoader.loadTestsFromName(path)
result = _runner().run(test)
sys.exit(not result.wasSuccessful())
示例13: main
def main():
# list of test modules
test_modules = ['testIntegrationUtilities',
'testPureAbsorberProblem',
'testPureScatteringProblem',
'testDiffusionProblem',
'testSSConvergence',
'testTransientSource',
'testRadTransient',
'testRadSpatialConvergence',
'testCreateMMSSourceFunctions',
'testHydroUniformIC']
# add all tests modules to suite
suite = TestSuite()
for test_module in test_modules:
suite.addTest(defaultTestLoader.loadTestsFromName(test_module))
# run suite
TextTestRunner(verbosity=2).run(suite)
示例14: test_suite
def test_suite():
return defaultTestLoader.loadTestsFromName(__name__)
示例15: test_suite
def test_suite():
if pingSolr():
return defaultTestLoader.loadTestsFromName(__name__)
else:
return TestSuite()