jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1181291?usp=email )

Change subject: tests: enable global options in script_tests
......................................................................

tests: enable global options in script_tests

script_tests calls pwb with script and local args, but the given
global options weren't taken. Now global arguments are saved in
bot.global_args and reused within script_tests.

Bug: T250034
Change-Id: Ibaf8ab0a58aa68417b4b0e6006ac0fd3ca8ac251
---
M pywikibot/bot.py
M tests/script_tests.py
2 files changed, 8 insertions(+), 1 deletion(-)

Approvals:
  Xqt: Looks good to me, approved
  jenkins-bot: Verified




diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 3ed0611..9aab5c2 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -278,6 +278,9 @@
 """Holds a user interface object defined in :mod:`pywikibot.userinterfaces`
 subpackage."""

+#: global args used by tests via pwb wrapper
+global_args: list[str] | None = None
+

 def set_interface(module_name: str) -> None:
     """Configures any bots to use the given interface module.
@@ -749,6 +752,9 @@
         # not the one in pywikibot.bot.
         args = pywikibot.argvu[1:]

+    global global_args
+    global_args = args
+
     # get the name of the module calling this function. This is
     # required because the -help option loads the module's docstring and
     # because the module name will be used for the filename of the log.
diff --git a/tests/script_tests.py b/tests/script_tests.py
index 6c0128c..356c6df 100755
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -14,6 +14,7 @@
 from pathlib import Path

 from pywikibot.backports import Iterator
+from pywikibot.bot import global_args as pwb_args
 from pywikibot.tools import has_module
 from tests import join_root_path, unittest_print
 from tests.aspects import DefaultSiteTestCase, MetaTestCaseClass, PwbTestCase
@@ -212,7 +213,7 @@
             def test_script(self) -> None:
                 global_args_msg = \
                     'For global options use -help:global or run pwb'
-                global_args = ['-pwb_close_matches:1']
+                global_args = (pwb_args or []) + ['-pwb_close_matches:1']

                 cmd = [*global_args, script_name, *args]
                 data_in = script_input.get(script_name)

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1181291?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.wikimedia.org/r/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ibaf8ab0a58aa68417b4b0e6006ac0fd3ca8ac251
Gerrit-Change-Number: 1181291
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <i...@gno.de>
Gerrit-Reviewer: Xqt <i...@gno.de>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- pywikibot-commits@lists.wikimedia.org
To unsubscribe send an email to pywikibot-commits-le...@lists.wikimedia.org

Reply via email to