jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1332463?usp=email )
Change subject: category_redirect: Fix delay option parsing
......................................................................
category_redirect: Fix delay option parsing
The option name returned by partition() excludes the colon. Match delay
instead of delay: so -delay:N is converted to an integer rather than a
boolean option.
Add focused coverage for the parsed bot option.
Change-Id: Ib13655905ce0c35f62b16c695de74030406068d3
---
M scripts/category_redirect.py
A tests/category_redirect_tests.py
2 files changed, 37 insertions(+), 1 deletion(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/scripts/category_redirect.py b/scripts/category_redirect.py
index 680e147..5ae0f31 100755
--- a/scripts/category_redirect.py
+++ b/scripts/category_redirect.py
@@ -578,7 +578,7 @@
continue
opt = opt[1:]
- if opt == 'delay:':
+ if opt == 'delay':
options[opt] = int(value)
elif opt == 'category':
options[opt] = value
diff --git a/tests/category_redirect_tests.py b/tests/category_redirect_tests.py
new file mode 100755
index 0000000..02f2235
--- /dev/null
+++ b/tests/category_redirect_tests.py
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+#
+# (C) Pywikibot team, 2026
+#
+# Distributed under the terms of the MIT license.
+#
+"""Tests for the category_redirect script."""
+from __future__ import annotations
+
+import unittest
+from unittest.mock import patch
+
+from scripts import category_redirect
+from tests.aspects import TestCase
+
+
+class CategoryRedirectMainTestCase(TestCase):
+
+ """Test :func:`category_redirect.main`."""
+
+ net = False
+
+ @patch.object(category_redirect, 'CategoryRedirectBot')
+ @patch.object(category_redirect.pywikibot.bot, 'suggest_help',
+ return_value=False)
+ @patch.object(category_redirect.pywikibot, 'handle_args',
+ side_effect=lambda args: args)
+ def test_delay_option(self, _, __, bot_mock) -> None:
+ """Test that the delay option is passed as an integer."""
+ category_redirect.main('-delay:14')
+
+ bot_mock.assert_called_once_with(delay=14)
+
+
+if __name__ == '__main__':
+ unittest.main()
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1332463?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: Ib13655905ce0c35f62b16c695de74030406068d3
Gerrit-Change-Number: 1332463
Gerrit-PatchSet: 2
Gerrit-Owner: Mahveotm <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]