예제 #1
0
 def runTest(self) -> None:
     """
     Go though all modules and launch the tests for every single one.
     """
     candidates_arobito = Lister.enlist_all_modules()
     candidates_tests = Lister.enlist_all_modules('tests')
     candidates = candidates_arobito + candidates_tests
     for module_name in candidates:
         if '.' in module_name:
             pod = module_name.split('.')
             mod = __import__(module_name, globals(), locals(), pod[-1])
         else:
             mod = __import__(module_name, globals(), locals())
         fields = dir(mod)
         self.__check_license(module_name, fields)
         self.__check_copyright(module_name, fields)
         self.__check_author(module_name, fields)
         self.__check_credits(module_name, fields)
         self.__check_maintainer(module_name, fields)
예제 #2
0
 def runTest(self) -> None:
     """
     Go though all modules and launch the tests for every single one.
     """
     candidates_arobito = Lister.enlist_all_modules()
     candidates_tests = Lister.enlist_all_modules('tests')
     candidates = candidates_arobito + candidates_tests
     for module_name in candidates:
         if '.' in module_name:
             pod = module_name.split('.')
             mod = __import__(module_name, globals(), locals(), pod[-1])
         else:
             mod = __import__(module_name, globals(), locals())
         fields = dir(mod)
         self.__check_license(module_name, fields)
         self.__check_copyright(module_name, fields)
         self.__check_author(module_name, fields)
         self.__check_credits(module_name, fields)
         self.__check_maintainer(module_name, fields)
예제 #3
0
def run_tests() -> int:
    """
    Get all classes and run the tests.

    :return: 0 when all tests succeeded, 1 otherwise.
    """
    print('===================', file=sys.stderr)
    print('Arobito Test Runner', file=sys.stderr)
    print('===================', file=sys.stderr)
    print(file=sys.stderr)

    test_classes = Lister.enlist_all_classes('tests')

    run_count = 0
    failure_count = 0
    error_count = 0
    case_count = 0

    suite = unittest.TestSuite()

    for test_class in test_classes:
        __import__(test_class.__module__)
        if not issubclass(test_class, unittest.TestCase):
            continue
        case_count += 1
        suite.addTest(test_class())
        print('[{:>6d}] Test Case "{:s}.{:s}" enlisted.'.format(
            case_count, test_class.__module__, test_class.__name__),
              file=sys.stderr)

    print(file=sys.stderr)
    print('Running tests', file=sys.stderr)
    runner = unittest.TextTestRunner()
    module_result = runner.run(suite)
    run_count += module_result.testsRun
    failure_count += len(module_result.failures)
    error_count += len(module_result.errors)

    print(file=sys.stderr)
    print('---------------------------', file=sys.stderr)
    print('Arobito Test Runner Results', file=sys.stderr)
    print('---------------------------', file=sys.stderr)
    print('Tests enlisted: {:d}'.format(case_count), file=sys.stderr)
    print('Tests ran: {:d}'.format(run_count), file=sys.stderr)
    print('Failures: {:d}'.format(failure_count), file=sys.stderr)
    print('Errors: {:d}'.format(error_count), file=sys.stderr)

    print(file=sys.stderr)
    if error_count > 0 or failure_count > 0:
        print('TEST RUN FAILED.', file=sys.stderr)
        return 1

    print('TEST RUN SUCCESSFUL.', file=sys.stderr)
    return 0
예제 #4
0
def run_tests() -> int:
    """
    Get all classes and run the tests.

    :return: 0 when all tests succeeded, 1 otherwise.
    """
    print('===================', file=sys.stderr)
    print('Arobito Test Runner', file=sys.stderr)
    print('===================', file=sys.stderr)
    print(file=sys.stderr)

    test_classes = Lister.enlist_all_classes('tests')

    run_count = 0
    failure_count = 0
    error_count = 0
    case_count = 0

    suite = unittest.TestSuite()

    for test_class in test_classes:
        __import__(test_class.__module__)
        if not issubclass(test_class, unittest.TestCase):
            continue
        case_count += 1
        suite.addTest(test_class())
        print('[{:>6d}] Test Case "{:s}.{:s}" enlisted.'
              .format(case_count, test_class.__module__, test_class.__name__), file=sys.stderr)

    print(file=sys.stderr)
    print('Running tests', file=sys.stderr)
    runner = unittest.TextTestRunner()
    module_result = runner.run(suite)
    run_count += module_result.testsRun
    failure_count += len(module_result.failures)
    error_count += len(module_result.errors)

    print(file=sys.stderr)
    print('---------------------------', file=sys.stderr)
    print('Arobito Test Runner Results', file=sys.stderr)
    print('---------------------------', file=sys.stderr)
    print('Tests enlisted: {:d}'.format(case_count), file=sys.stderr)
    print('Tests ran: {:d}'.format(run_count), file=sys.stderr)
    print('Failures: {:d}'.format(failure_count), file=sys.stderr)
    print('Errors: {:d}'.format(error_count), file=sys.stderr)

    print(file=sys.stderr)
    if error_count > 0 or failure_count > 0:
        print('TEST RUN FAILED.', file=sys.stderr)
        return 1

    print('TEST RUN SUCCESSFUL.', file=sys.stderr)
    return 0