当前位置: 首页>>代码示例>>Python>>正文


Python defaultTestLoader.loadTestsFromName函数代码示例

本文整理汇总了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)
开发者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


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