Beispiel #1
0
def collector(loader=unittest.loader.defaultTestLoader):
    """Load the default tests."""
    # Note: Raising SkipTest during load_tests will
    # cause the loader to fallback to its own
    # discover() ordering of unit tests.

    enable_autorun_tests = (os.environ.get('PYWIKIBOT2_TEST_AUTORUN',
                                           '0') == '1')

    tests = (['test__login_execution'] + [
        'test_' + name + '_execution' for name in sorted(script_list)
        if name != 'login' and name not in deadlock_script_list
    ] + ['test__login_no_args'])

    tests += [
        'test_' + name + '_no_args' for name in sorted(script_list)
        if name != 'login' and name not in deadlock_script_list
        and name not in failed_dep_script_list  # no_args = execution
        and name not in unrunnable_script_list and (
            enable_autorun_tests or name not in auto_run_script_list)
    ]

    test_list = ['tests.script_tests.TestScript.' + name for name in tests]

    tests = loader.loadTestsFromNames(test_list)
    suite = unittest.TestSuite()
    suite.addTests(tests)
    return suite
Beispiel #2
0
def collector(loader=unittest.loader.defaultTestLoader):
    """Load the default tests."""
    # Note: Raising SkipTest during load_tests will
    # cause the loader to fallback to its own
    # discover() ordering of unit tests.

    enable_autorun_tests = (
        os.environ.get('PYWIKIBOT2_TEST_AUTORUN', '0') == '1')

    if deadlock_script_list:
        print('Skipping deadlock scripts:\n  %s'
              % ', '.join(deadlock_script_list))

    if unrunnable_script_list:
        print('Skipping execution of unrunnable scripts:\n  %r'
              % unrunnable_script_list)

    if not enable_autorun_tests:
        print('Skipping execution of auto-run scripts '
              '(set PYWIKIBOT2_TEST_AUTORUN=1 to enable):\n  %r'
              % auto_run_script_list)

    tests = (['test__login_help'] +
             ['test_' + name + '_help'
              for name in sorted(script_list)
              if name != 'login'
              and name not in deadlock_script_list] +
             ['test__login_simulate'])

    tests += ['test_' + name + '_simulate'
              for name in sorted(script_list)
              if name != 'login'
              and name not in deadlock_script_list
              and name not in failed_dep_script_list
              and name not in unrunnable_script_list
              and (enable_autorun_tests or name not in auto_run_script_list)]

    test_list = ['tests.script_tests.TestScript.' + name
                 for name in tests]

    tests = loader.loadTestsFromNames(test_list)
    suite = unittest.TestSuite()
    suite.addTests(tests)
    return suite
Beispiel #3
0
def collector(loader=unittest.loader.defaultTestLoader):
    """Load the default tests."""
    # Note: Raising SkipTest during load_tests will
    # cause the loader to fallback to its own
    # discover() ordering of unit tests.

    if unrunnable_script_set:
        unittest_print('Skipping execution of unrunnable scripts:\n  {!r}'
                       .format(unrunnable_script_set))

    if not enable_autorun_tests:
        unittest_print('Skipping execution of auto-run scripts '
                       '(set PYWIKIBOT_TEST_AUTORUN=1 to enable):\n  {!r}'
                       .format(auto_run_script_list))

    tests = (['test__login']
             + ['test_' + name
                 for name in sorted(script_list)
                 if name != 'login'
                 and name not in unrunnable_script_set
                ])

    test_list = ['tests.script_tests.TestScriptHelp.' + name
                 for name in tests]

    tests = (['test__login']
             + ['test_' + name
                 for name in sorted(script_list)
                 if name != 'login'
                 and name not in failed_dep_script_set
                 and name not in unrunnable_script_set
                 and (enable_autorun_tests or name not in auto_run_script_list)
                ])

    test_list += ['tests.script_tests.TestScriptSimulate.' + name
                  for name in tests]

    tests = loader.loadTestsFromNames(test_list)
    suite = unittest.TestSuite()
    suite.addTests(tests)
    return suite