Exemplo n.º 1
0
def run_suite(suite):
    if cfg.tap_protocol_enabled():
        try:
            from tap import TAPTestRunner
            runner = TAPTestRunner()
            runner.set_stream(True)
        except ImportError as e:
            log.error('No TAP test runner found: %s', e)
            raise
    else:
        runner = ut.TextTestRunner(verbosity=1)

    result = runner.run(suite)
    sys.exit(not result.wasSuccessful())
Exemplo n.º 2
0
        setup.wait()
        if setup.returncode != 0:
            raise Exception('Setup failed')


def run_teardowns(tests):
    teardowns = []
    for test in tests:
        test_dir = path_from_name(test[0], 'plain')
        if os.path.isfile(os.path.join(test_dir, 'teardown.sh')):
            teardowns.append(
                subprocess.Popen('./teardown.sh',
                                 cwd=test_dir,
                                 stdout=subprocess.DEVNULL,
                                 stderr=subprocess.DEVNULL))
    for teardown in teardowns:
        teardown.wait()


if __name__ == '__main__':
    tests = get_test_cases()
    run_setups(tests)
    suite = unittest.TestSuite()
    for test in tests:
        suite.addTest(test[1]())
    runner = TAPTestRunner()
    runner.set_format('{method_name}')
    runner.set_stream(True)
    runner.run(suite)
    run_teardowns(tests)
Exemplo n.º 3
0
# Copyright (c) 2015, Matt Layman

import os
import unittest

from tap import TAPTestRunner

if __name__ == '__main__':
    tests_dir = os.path.dirname(os.path.abspath(__file__))
    loader = unittest.TestLoader()
    tests = loader.discover(tests_dir)
    runner = TAPTestRunner()
    runner.set_outdir('testout')
    runner.set_format('Hi: {method_name} - {short_description}')
    runner.run(tests)
Exemplo n.º 4
0
 def execute(self):
     runner = TAPTestRunner()
     runner.set_outdir('logs/TAP/')
     runner.set_format('{method_name} and {short_description}')
     runner.set_combined(True)
     runner.run(self.suite)
Exemplo n.º 5
0
                                           stderr=subprocess.DEVNULL))
    for setup in setups:
        setup.wait()
        if setup.returncode != 0:
            raise Exception('Setup failed')


def run_teardowns(tests):
    teardowns = []
    for test in tests:
        test_dir = path_from_name(test[0], 'plain')
        if os.path.isfile(os.path.join(test_dir, 'teardown.sh')):
            teardowns.append(subprocess.Popen('./teardown.sh', cwd=test_dir,
                                              stdout=subprocess.DEVNULL,
                                              stderr=subprocess.DEVNULL))
    for teardown in teardowns:
        teardown.wait()


if __name__ == '__main__':
    tests = get_test_cases()
    run_setups(tests)
    suite = unittest.TestSuite()
    for test in tests:
        suite.addTest(test[1]())
    runner = TAPTestRunner()
    runner.set_format('{method_name}')
    runner.set_stream(True)
    runner.run(suite)
    run_teardowns(tests)
Exemplo n.º 6
0
    )

    args = argparser.parse_args()

    loader = unittest.TestLoader()

    start_dir = args.start_dir
    pattern = args.pattern
    failfast = args.failfast
    test_case = args.test_case

    if test_case:
        sys.path.append(start_dir)
        tests = loader.loadTestsFromName(test_case)
    elif pattern:
        tests = loader.discover(start_dir, pattern)
    else:
        # This will never happen because the mutual exclusion group has the
        # `required` parameter set to True. So one or the other must be set or
        # else it will fail to parse.
        sys.exit(1)

    if tests.countTestCases() < 1:
        print("No tests matching '%s' found in '%s'" % (pattern, start_dir))
        sys.exit(1)

    runner = TAPTestRunner(failfast=failfast)
    runner.set_stream(True)
    runner.set_format('{method_name}')
    sys.exit(0 if runner.run(tests).wasSuccessful() else 1)
Exemplo n.º 7
0
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

from tap import TAPTestRunner
import unittest
import sys


if __name__ == '__main__':
    loader = unittest.TestLoader()
    tests = loader.discover(sys.argv[1])
    runner = TAPTestRunner()
    runner.set_stream(True)
    runner.set_format('{method_name}')
    sys.exit(0 if runner.run(tests).wasSuccessful() else 1)
Exemplo n.º 8
0
# Copyright (c) 2019, Matt Layman and contributors

import os
import sys
import unittest

from tap import TAPTestRunner

if __name__ == "__main__":
    tests_dir = os.path.dirname(os.path.abspath(__file__))
    loader = unittest.TestLoader()
    tests = loader.discover(tests_dir)
    runner = TAPTestRunner()
    runner.set_outdir("testout")
    runner.set_format("Hi: {method_name} - {short_description}")
    result = runner.run(tests)
    status = 0 if result.wasSuccessful() else 1
    sys.exit(status)