jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/742169 )
Change subject: [tests] Only find one alternative script with script_tests.py
......................................................................
[tests] Only find one alternative script with script_tests.py
utils.execute_pwb imports pwb and pywikibot and config variable cannot
be set directly for that environment and will be ignored. To set the
pwb_close_matches variable use the global argument handling.
This partly reverts change-ID I90d9243
Bug: T296204
Change-Id: If737765748115bc93770945832ab76999bd5e92b
---
M tests/script_tests.py
1 file changed, 8 insertions(+), 19 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/script_tests.py b/tests/script_tests.py
index cb88909..6f9b47f 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -10,14 +10,12 @@
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.
@@ -45,7 +43,7 @@
if not check_script_deps(name)}
# scripts which cannot be tested
-unrunnable_script_set = {'commonscat'}
+unrunnable_script_set = set()
def list_scripts(path, exclude=None):
@@ -57,8 +55,7 @@
return scripts
-script_list = (['login']
- + list_scripts(scripts_path, 'login.py'))
+script_list = ['login'] + list_scripts(scripts_path, exclude='login.py')
script_input = {
'interwiki': 'Test page that should not exist\n',
@@ -196,9 +193,11 @@
.format(script_name))
def test_script(self):
- global_args = 'For global options use -help:global or run pwb'
+ global_args_msg = \
+ 'For global options use -help:global or run pwb'
+ global_args = ['-pwb_close_matches:1']
- cmd = [script_name] + args
+ cmd = global_args + [script_name] + args
data_in = script_input.get(script_name)
timeout = 5 if is_autorun else None
@@ -238,7 +237,7 @@
elif not is_autorun:
if not stderr_other:
- self.assertIn(global_args, out_result)
+ self.assertIn(global_args_msg, out_result)
else:
self.assertIn('Use -help for further information.',
stderr_other)
@@ -267,7 +266,7 @@
self.assertNotIn('deprecated', err_result.lower())
# If stdout doesn't include global help..
- if global_args not in out_result:
+ if global_args_msg not in out_result:
# Specifically look for deprecated
self.assertNotIn('deprecated', out_result.lower())
# But also complain if there is any stdout
@@ -368,16 +367,6 @@
_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()
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/742169
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: If737765748115bc93770945832ab76999bd5e92b
Gerrit-Change-Number: 742169
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged