jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/740899 )
Change subject: [tests] Only find one alternative script with script_tests.py ......................................................................
[tests] Only find one alternative script with script_tests.py
Also uncomment code parts from previous debugging and update tox.ini
Bug: T296204 Change-Id: I90d92434b47e0890cc61720c55d7f0205ab166ae --- M tests/script_tests.py M tox.ini 2 files changed, 28 insertions(+), 17 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/script_tests.py b/tests/script_tests.py index b1e3968..cb88909 100644 --- a/tests/script_tests.py +++ b/tests/script_tests.py @@ -10,11 +10,14 @@ from contextlib import suppress
from pywikibot.tools import has_module +from pywikibot import config + from tests import join_root_path, unittest_print from tests.aspects import DefaultSiteTestCase, MetaTestCaseClass, PwbTestCase from tests.utils import execute_pwb
+saved_pwb_close_matches = config.pwb_close_matches scripts_path = join_root_path('scripts')
# These dependencies are not always the package name which is in setup.py. @@ -54,9 +57,8 @@ return scripts
-##script_list = (['login'] -## + list_scripts(scripts_path, 'login.py')) -script_list = ['login', 'add_text', 'archivebot', 'basic', 'blockpageschecker'] +script_list = (['login'] + + list_scripts(scripts_path, 'login.py'))
script_input = { 'interwiki': 'Test page that should not exist\n', @@ -150,17 +152,17 @@ 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 = (['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() @@ -193,7 +195,7 @@ 'PYWIKIBOT_TEST_AUTORUN=1 to enable) "{}"' .format(script_name))
- def testScript(self): + def test_script(self): global_args = 'For global options use -help:global or run pwb'
cmd = [script_name] + args @@ -279,7 +281,7 @@
if not enable_autorun_tests and is_autorun: return test_skip_script - return testScript + return test_script
arguments = dct['_arguments']
@@ -366,6 +368,16 @@ _results = no_args_expected_results
+def setUpModule(): # noqa: N802 + """Only find one alternative script (T296204).""" + config.pwb_close_matches = 1 + + +def tearDownModule(): # noqa: N802 + """Restore pwb_close_matches setting.""" + config.pwb_close_matches = saved_pwb_close_matches + + if __name__ == '__main__': # pragma: no cover with suppress(SystemExit): unittest.main() diff --git a/tox.ini b/tox.ini index d76165b..47069fb 100644 --- a/tox.ini +++ b/tox.ini @@ -211,7 +211,6 @@ tests/page_tests.py: E241, N802 tests/pagegenerators_tests.py: N802 tests/pwb/*: T001 - tests/script_tests.py: N802, E265, E266, E501 tests/site_detect_tests.py: N802 tests/site_tests.py: N802 tests/sparql_tests.py: N802