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

Python defaultTestLoader.loadTestsFromName函数代码示例

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

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



在下文中一共展示了loadTestsFromName函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:bjcohen,项目名称:python-lzw,代码行数:12,代码来源:setup.py


示例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')
开发者ID:joeatwork,项目名称:python-lzw,代码行数:15,代码来源:setup.py


示例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())
开发者ID:ryanhorn,项目名称:gevent,代码行数:34,代码来源:testrunner.py


示例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())
开发者ID:alexstoick,项目名称:ruby_tests,代码行数:26,代码来源:testrunner.py


示例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())
开发者ID:vijvijay,项目名称:rapidapp,代码行数:28,代码来源:testrunner.py


示例6: suite

def suite():
    suite = doctest.DocFileSuite(
        'test_loader.py',
        'test_views.py')
    suite.addTest(defaultTestLoader.loadTestsFromName(
            'yui_loader.tests.test_middleware'))
    return suite
开发者ID:akaihola,项目名称:django-yui-loader,代码行数:7,代码来源:__init__.py


示例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__]
    )
开发者ID:HackLinux,项目名称:chandler-1,代码行数:8,代码来源:__init__.py


示例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
开发者ID:collective,项目名称:collective.usernamelogger,代码行数:8,代码来源:tests.py


示例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)
开发者ID:mathvaleriano,项目名称:mongorest,代码行数:9,代码来源:setup.py


示例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
开发者ID:andymccurdy,项目名称:wtforms,代码行数:12,代码来源:runtests.py


示例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
开发者ID:RobinVan,项目名称:wtforms,代码行数:15,代码来源:runtests.py


示例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())
开发者ID:cta08403,项目名称:gevent-for-ios,代码行数:45,代码来源:testrunner.py


示例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)
开发者ID:jhansel,项目名称:radhydro,代码行数:20,代码来源:testAll.py


示例14: test_suite

def test_suite():
    return defaultTestLoader.loadTestsFromName(__name__)
开发者ID:andrgrau,项目名称:collective.solr,代码行数:2,代码来源:test_integration.py


示例15: test_suite

def test_suite():
    if pingSolr():
        return defaultTestLoader.loadTestsFromName(__name__)
    else:
        return TestSuite()
开发者ID:RedTurtle,项目名称:collective.solr,代码行数:5,代码来源:test_facets.py


示例16: test_suite

def test_suite():
    if hasLinguaPlone():
        return defaultTestLoader.loadTestsFromName(__name__)
    else:
        return TestSuite()
开发者ID:CGTIC,项目名称:Plone_SP,代码行数:5,代码来源:test_linguaplone.py


示例17: test_suite

def test_suite():
    from unittest import defaultTestLoader as loader
    return loader.loadTestsFromName("tests.licensekey")
开发者ID:IanLewis,项目名称:pyaws,代码行数:3,代码来源:licensekey.py


示例18: len

    if options.host:
        test_config.HOST_NAME = options.host
    if options.username:
        test_config.USERNAME = options.username
    if options.password:
        test_config.PASSWORD = options.password
    if options.password:
        test_config.SECRET = options.secret

    test_config.memcache = options.memcache == "1"
    test_config.SERVER_BASE = "%s://%s" % (test_config.SCHEME,
                                           test_config.SERVER_NAME)
    tests = args
    any_problems = False

    if len(tests) > 0:
        results = []
        runner = TextTestRunner(verbosity=3)
        for test in tests:
            test = defaultTestLoader.loadTestsFromName(test,
                                                       module=server_tests)
            results.append(runner.run(test))
    else:
        results = run()

    for result in results:
        if len(result.failures + result.errors) > 0:
            sys.exit(1)

    sys.exit(0)
开发者ID:FilipinOTech,项目名称:server-full,代码行数:30,代码来源:run_server_tests.py


示例19: run

"""

Test runner which uses unittest ``discover`` method to find all
tests within ``cauliflower.testsuite`` and run them.

"""
import sys
import argparse

# TODO: try to import unittest2 for python2.4-2.6 backward compatibility
from unittest import TextTestRunner, defaultTestLoader


TESTSUITE_DIR = 'testsuite'


if __name__ == '__main__':
    parser = argparse.ArgumentParser(description="Yes! It runs the test in testsuite")
    parser.add_argument('--test', help="which test to run (dotted test path)")
    args = parser.parse_args()
    test = args.test

    # needs to discover before accessing specific tests
    test_suite = defaultTestLoader.discover(TESTSUITE_DIR)

    if test is not None:
        path = '.'.join((TESTSUITE_DIR, test))
        test_suite = defaultTestLoader.loadTestsFromName(path)

    TextTestRunner(verbosity=1).run(test_suite)
开发者ID:jontech,项目名称:couliflower,代码行数:30,代码来源:runtests.py


示例20: suite

def suite():
    return defaultTestLoader.loadTestsFromName('pyomgidl.reader.tests')
开发者ID:moriyoshi,项目名称:pyOMGIDL,代码行数:2,代码来源:tests.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python defaultTestLoader.loadTestsFromTestCase函数代码示例发布时间:2022-05-27
下一篇:
Python unittest.TextTestRunner类代码示例发布时间: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