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


Python TextTestRunner.wasSuccessful方法代码示例

本文整理汇总了Python中unittest.TextTestRunner.wasSuccessful方法的典型用法代码示例。如果您正苦于以下问题:Python TextTestRunner.wasSuccessful方法的具体用法?Python TextTestRunner.wasSuccessful怎么用?Python TextTestRunner.wasSuccessful使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在unittest.TextTestRunner的用法示例。


在下文中一共展示了TextTestRunner.wasSuccessful方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: run

# 需要导入模块: from unittest import TextTestRunner [as 别名]
# 或者: from unittest.TextTestRunner import wasSuccessful [as 别名]
    def run(self):
        # Do not include current directory, validate using installed pythran
        current_dir = _exclude_current_dir_from_import()
        os.chdir("pythran/tests")
        where = os.path.join(current_dir, 'pythran')

        from pythran import test_compile
        test_compile()

        try:
            import py
            import xdist
            args = ["-n", str(self.num_threads), where, '--pep8']
            if self.failfast:
                args.insert(0, '-x')
            if self.cov:
                try:
                    import pytest_cov
                    args = ["--cov-report", "html",
                            "--cov-report", "annotate",
                            "--cov", "pythran"] + args
                except ImportError:
                    print ("W: Skipping coverage analysis, pytest_cov"
                           "not found")
            if py.test.cmdline.main(args) == 0:
                print "\\_o<"
        except ImportError:
            print ("W: Using only one thread, "
                   "try to install pytest-xdist package")
            loader = TestLoader()
            t = TextTestRunner(failfast=self.failfast)
            t.run(loader.discover(where))
            if t.wasSuccessful():
                print "\\_o<"
开发者ID:baoboa,项目名称:pythran,代码行数:36,代码来源:setup.py

示例2: RunTest

# 需要导入模块: from unittest import TextTestRunner [as 别名]
# 或者: from unittest.TextTestRunner import wasSuccessful [as 别名]
def RunTest(test):
    global TestLoader, TextTestRunner
    testItem = TestLoader().loadTestsFromTestCase(test)
    res = TextTestRunner(verbosity=2).run(testItem)

    if not res.wasSuccessful():
        raise Exception("Unit test failed")
开发者ID:deniskoronchik,项目名称:sc-machine,代码行数:9,代码来源:sc_test.py

示例3: run_unit_tests

# 需要导入模块: from unittest import TextTestRunner [as 别名]
# 或者: from unittest.TextTestRunner import wasSuccessful [as 别名]
def run_unit_tests():
    from unittest import TextTestRunner

    from tests.unittest import load_tests

    result = TextTestRunner(verbosity=2).run(load_tests())
    if not result.wasSuccessful():
        raise RuntimeError("Unittest failed.")
开发者ID:ricequant,项目名称:rqalpha,代码行数:10,代码来源:test.py

示例4: run

# 需要导入模块: from unittest import TextTestRunner [as 别名]
# 或者: from unittest.TextTestRunner import wasSuccessful [as 别名]
 def run(self):
     from unittest import (TestLoader, TextTestRunner, )
     if IS_OLD_PYTHON2:
         try:
             from unittest2 import (TestLoader, TextTestRunner, )
         except ImportError:
             print('You should use the python version above 2.7 or install unittest2.')
             sys.exit(1)
     path_to_tests = path.join('namedparser', 'testsuite')
     testsuites = TestLoader().discover(path.join(BASE_DIR, path_to_tests))
     result = TextTestRunner(verbosity=1).run(testsuites)
     sys.exit(not result.wasSuccessful())
开发者ID:hachibeeDI,项目名称:namedparser,代码行数:14,代码来源:setup.py

示例5: run_test_suite

# 需要导入模块: from unittest import TextTestRunner [as 别名]
# 或者: from unittest.TextTestRunner import wasSuccessful [as 别名]
def run_test_suite():

    cov = Coverage(config_file=True)
    cov.erase()
    cov.start()

    # Announce the test suite
    sys.stdout.write(colored(text="\nWelcome to the ", color="magenta", attrs=["bold"]))
    sys.stdout.write(colored(text="python-doc-inherit", color="green", attrs=["bold"]))
    sys.stdout.write(colored(text=" test suite.\n\n", color="magenta", attrs=["bold"]))

    # Announce test run
    print(colored(text="Step 1: Running unit tests.\n", color="yellow", attrs=["bold"]))

    test_suite = TestLoader().discover(str(Path("tests").absolute()))
    result = TextTestRunner(verbosity=1).run(test_suite)

    if not result.wasSuccessful():
        sys.exit(len(result.failures) + len(result.errors))

    # Announce coverage run
    print(colored(text="\nStep 2: Generating coverage results.\n", color="yellow", attrs=["bold"]))

    cov.stop()
    percentage = round(cov.report(show_missing=True), 2)
    cov.html_report(directory='cover')
    cov.save()

    if percentage < TESTS_THRESHOLD:
        print(colored(text="YOUR CHANGES HAVE CAUSED TEST COVERAGE TO DROP. " +
                           "WAS {old}%, IS NOW {new}%.\n".format(old=TESTS_THRESHOLD, new=percentage),
                           color="red", attrs=["bold"]))
        sys.exit(1)

    # Announce flake8 run
    sys.stdout.write(colored(text="\nStep 3: Checking for pep8 errors.\n\n", color="yellow", attrs=["bold"]))

    print("pep8 errors:")
    print("----------------------------------------------------------------------")

    from subprocess import call
    flake_result = call(["flake8", ".", "--count"])
    if flake_result != 0:
        print("pep8 errors detected.")
        print(colored(text="\nYOUR CHANGES HAVE INTRODUCED PEP8 ERRORS!\n", color="red", attrs=["bold"]))
        sys.exit(flake_result)
    else:
        print("None")

    # Announce success
    print(colored(text="\nTests completed successfully with no errors. Congrats!", color="green", attrs=["bold"]))
开发者ID:kavdev,项目名称:python-doc-inherit,代码行数:53,代码来源:runtests.py

示例6: step

# 需要导入模块: from unittest import TextTestRunner [as 别名]
# 或者: from unittest.TextTestRunner import wasSuccessful [as 别名]
    def step(self, msg, list_of_steps, assert_success=True):
        from unittest import TestSuite as TS, makeSuite as sweeten, TextTestRunner as Runner

        sweet = TS()

        if not isinstance(list_of_steps, list):
            list_of_steps = [list_of_steps]

        for test in list_of_steps:
            sweet.addTest(sweeten(test))

        result = Runner().run(sweet)

        if assert_success:
            self.assertTrue(result.wasSuccessful(), msg)
            print(msg + ": [ OK ]")
开发者ID:gitter-badger,项目名称:Skoarcery,代码行数:18,代码来源:Buildoar.py

示例7: main

# 需要导入模块: from unittest import TextTestRunner [as 别名]
# 或者: from unittest.TextTestRunner import wasSuccessful [as 别名]
def main():
    """Run the Wall code quality checks."""
    print("Running unit tests...")
    # TODO: tests = defaultTestLoader.discover('.')
    tests = defaultTestLoader.loadTestsFromNames(["wall", "wall.util", "wall.bricks.url"])
    test_result = TextTestRunner(stream=sys.stdout).run(tests)

    print("\nLinting (Python)...")
    linter = PyLinter()
    linter.load_default_plugins()
    linter.load_file_configuration()
    linter.load_configuration(ignore="lib")
    # TODO: linter.check(['wall', 'walld.py', 'sjmpc.py', 'check.py'])
    linter.check(["wall.util", "walld.py", "check.py"])

    print("\nLinting (text)...")
    checkre_result = checkre(
        {
            (
                r"(?!.*/lib/).*\.(html|css)",
                r"wall/res/default.cfg",
                r"wall/res/static/(display|remote)/config.default.json",
                r"pylintrc",
            ): (
                line_length_check(),
                simple_indentation_check(),
                trailing_space_check(),
                whitespace_check(),
                newline_at_eof_check(),
            ),
            r"(?!.*/lib/).*\.md": (
                line_length_check(),
                trailing_space_check(),
                whitespace_check(),
                newline_at_eof_check(),
            ),
            r"(?!.*/lib/|walld.py|sjmpc.py|check.py).*\.py": header_check("wall/__init__.py", 2),
            r"(?!.*/lib/).*\.js": header_check("wall/res/static/wall.js", 4),
        }
    )

    if not test_result.wasSuccessful() or linter.msg_status != 0 or checkre_result != 0:
        return 1

    print("\nEverything looks fine, good work!")
    return 0
开发者ID:NoyaInRain,项目名称:wall,代码行数:48,代码来源:check.py

示例8: RunTests

# 需要导入模块: from unittest import TextTestRunner [as 别名]
# 或者: from unittest.TextTestRunner import wasSuccessful [as 别名]
def RunTests():
  global TestLoader, TextTestRunner, MemoryCtx
  
  tests = [
    TestScAddr,
    TestScType,
    TestScMemoryContext,
    TestScSet,
    TestEvents,
    TestScHelper,
    ]

  for testItem in tests:
    testItem.MemoryCtx = MemoryCtx
    testItem.module = module
    suite = defaultTestLoader.loadTestsFromTestCase(testItem)
    res = TextTestRunner(verbosity=2).run(suite)
    if not res.wasSuccessful():
      raise Exception("Unit test failed")
开发者ID:ShunkevichDV,项目名称:sc-machine,代码行数:21,代码来源:test_main.py

示例9: sort

# 需要导入模块: from unittest import TextTestRunner [as 别名]
# 或者: from unittest.TextTestRunner import wasSuccessful [as 别名]
             test_aggregated_pieces.IMPORTER_SUITE,
             test_indexed_piece.INDEXED_PIECE_SUITE_A,
             test_indexed_piece.INDEXED_PIECE_PARTS_TITLES,
             test_indexed_piece.INDEXED_PIECE_SUITE_C,
             test_aggregated_pieces.AGGREGATED_PIECES_SUITE,
             # NB: Most of these WorkflowManager tests pass but they are commented out because the WorkflowManager is deprecated.
             # # WorkflowManager 
             # test_workflow.WORKFLOW_TESTS,  # FutureWarning: sort(columns) is depracated, use sort_values(by=...)
             # test_workflow.FILTER_DATA_FRAME,
             # test_workflow.MAKE_TABLE,
             # test_workflow.EXTRA_PAIRS,
             # test_workflow.SETTINGS,
             # test_workflow.OUTPUT,
             # test_workflow.MAKE_HISTOGRAM,
             # test_workflow.MAKE_LILYPOND,
             # test_workflow.AUX_METHODS,
             # test_workflow_experiments.INTERVALS,
             # Integration Tests
             bwv2.ALL_VOICE_INTERVAL_NGRAMS,
             bwv603.ALL_VOICE_INTERVAL_NGRAMS,
             # NB: The integration tests below are commented out because the WorkflowManager is deprecated.
             # test_workflow_integration.INTERVALS_TESTS,
        )


if __name__ == '__main__':
    for each_test in THE_TESTS:
        result = TextTestRunner(verbosity=VERBOSITY, descriptions=False).run(each_test)
        if not result.wasSuccessful():
            raise RuntimeError('Test failure')
开发者ID:ELVIS-Project,项目名称:vis-framework,代码行数:32,代码来源:run_tests.py

示例10: TestLoader

# 需要导入模块: from unittest import TextTestRunner [as 别名]
# 或者: from unittest.TextTestRunner import wasSuccessful [as 别名]
from lib.common import do
from lib import db
from os.path import basename

# from lib import dl
# dl.trace_start("trace.html",interval=5,auto=True)
if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('command', metavar='COMMAND', help='command: init, tests')
    parser.add_argument('-c', '--config', metavar='CONFIG', help='config file')
    args = parser.parse_args()

    if args.command == 'tests':
        suite = TestLoader().discover('tests', pattern='*.py')
        result = TextTestRunner(verbosity=2).run(suite)
        result = 0 if result.wasSuccessful() else 1
        exit(result)

    cfg = read_config(args.config)
    logger = init_logger()

    renderer = DistributedRenderer()
    qualifier = DistributedQualifier()
    base_image_path = cfg['main']['populationPath'] + basename(cfg['main']['baseImage'])
    fitnessMachine = MeshFitnessMachine(base_image_path, renderer, qualifier)
    population = Population(MeshGenome, fitnessMachine)
    population.generation = int(db.get('generation', default=0))

    accuracy.register(population)
    monitor.register(population)
开发者ID:Eyjafjallajokull,项目名称:gengen,代码行数:32,代码来源:main.py

示例11: TestLoader

# 需要导入模块: from unittest import TextTestRunner [as 别名]
# 或者: from unittest.TextTestRunner import wasSuccessful [as 别名]
test_modules = [test_core, test_csv, test_database, test_datatypes, test_dispatcher,
    test_gettext, test_handlers, test_html, test_i18n, test_ical, test_odf,
    test_rss, test_srx, test_stl, test_tmx, test_uri, test_fs,
    test_validators, test_web, test_workflow, test_xliff, test_xml, test_xmlfile]


loader = TestLoader()

if __name__ == '__main__':
    usage = '%prog [OPTIONS]'
    description = 'Run ikaaro tests'
    parser = OptionParser(usage, description=description)
    parser.add_option('-m', '--mode', default='standard', help='tests mode')
    options, args = parser.parse_args()
    suite = TestSuite()
    for module in test_modules:
        suite.addTest(loader.loadTestsFromModule(module))
    if options.mode == 'standard':
        ret = TextTestRunner(verbosity=1).run(suite)
    elif options.mode == 'junitxml':
        path = get_abspath('./junit.xml')
        print('Result is here: %s' % path)
        f = file(path, 'wb')
        result = JUnitXmlResult(f)
        result.startTestRun()
        ret = suite.run(result)
        result.stopTestRun()
    exit_code = not ret.wasSuccessful()
    exit(exit_code)
开发者ID:hforge,项目名称:itools,代码行数:31,代码来源:test.py

示例12: run_tests

# 需要导入模块: from unittest import TextTestRunner [as 别名]
# 或者: from unittest.TextTestRunner import wasSuccessful [as 别名]
 def run_tests(self):
     from unittest import TestLoader, TextTestRunner
     tests_dir = pjoin(dirname(__file__), 'tests')
     suite = TestLoader().discover(tests_dir)
     result = TextTestRunner().run(suite)
     sys.exit(0 if result.wasSuccessful() else -1)
开发者ID:gruns,项目名称:orderedmultidict,代码行数:8,代码来源:setup.py

示例13: TestSuite

# 需要导入模块: from unittest import TextTestRunner [as 别名]
# 或者: from unittest.TextTestRunner import wasSuccessful [as 别名]
    MobileDetection.uas = uas
    MobileDetection.expected = expected
    suite = TestSuite()
    for x in range(len(uas)):
        if not uas[x].startswith('#'):
            setattr(MobileDetection, 'test%s' % x, testnum(x))
            suite.addTest(MobileDetection('test%s' % x))
    return suite


def suite_from_file(filename, expected):
    with open(os.path.join(os.path.dirname(__file__), filename)) as f:
        uas = f.readlines()

    return MobileDetectionFactory(uas=uas, expected=expected)


def gen_suite():
    suite = TestSuite()
    suite.addTest(suite_from_file('mobile_useragents.txt', True))
    suite.addTest(suite_from_file('other_useragents.txt', False))
    suite.addTests(TestLoader().loadTestsFromTestCase(TestHTTPHeaders))
    return suite

suite = gen_suite()


if __name__ in ("minidetector.tests", "__main__"):
    result = TextTestRunner().run(suite)
    sys.exit(int(not result.wasSuccessful()))
开发者ID:Moco,项目名称:django-minidetector,代码行数:32,代码来源:__init__.py

示例14: name

# 需要导入模块: from unittest import TextTestRunner [as 别名]
# 或者: from unittest.TextTestRunner import wasSuccessful [as 别名]
#!/usr/bin/env python

import os
import sys
from unittest import TestLoader
from unittest import TextTestRunner, TestSuite


"""
NOTE: "If a test package name (directory with __init__.py) matches the pattern
       then the package will be checked for a load_tests function. If this
       exists then it will be called with loader, tests, pattern."
"""

"""
Load all tests in the current directory and run them
"""
if __name__ == "__main__":
    # must set the path for the imported tests
    sys.path.insert(0, os.path.abspath('../..'))

    loader = TestLoader()
    suite = TestSuite(loader.discover(start_dir='.', pattern='*_test.py',
                                      top_level_dir="."))

    result = TextTestRunner(verbosity=2).run(suite)
    if result.wasSuccessful():
        sys.exit(0)

    sys.exit(1)
开发者ID:lanjiantm,项目名称:python-irodsclient,代码行数:32,代码来源:runner.py

示例15: TestLoader

# 需要导入模块: from unittest import TextTestRunner [as 别名]
# 或者: from unittest.TextTestRunner import wasSuccessful [as 别名]
#!/usr/bin/env python3

from unittest import TestLoader, TextTestRunner
from sys import argv, exit

if __name__ == "__main__":
    suite = TestLoader().discover('tests', pattern = "test_*.py")
    v = 1
    if len(argv) > 1:
        if argv[1] == 'verbose':
            v = 2
        elif argv[1] == 'quiet':
            v = 0
    ret = TextTestRunner(verbosity=v).run(suite)
    exit(not ret.wasSuccessful())
开发者ID:rearn,项目名称:konata-nikki,代码行数:17,代码来源:runtest.py


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