Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1319946?usp=email )
Change subject: tests: Add unlinkbot_tests.py ......................................................................
tests: Add unlinkbot_tests.py
Change-Id: I0ed9b7f296a580c5559e572d8ec9374f8d856016 --- M pywikibot/specialbots/__init__.py M tests/__init__.py A tests/unlinkbot_tests.py 3 files changed, 54 insertions(+), 1 deletion(-)
Approvals: Xqt: Verified; Looks good to me, approved
diff --git a/pywikibot/specialbots/__init__.py b/pywikibot/specialbots/__init__.py index f504bb5..e620726 100644 --- a/pywikibot/specialbots/__init__.py +++ b/pywikibot/specialbots/__init__.py @@ -6,12 +6,17 @@ """Module containing special bots reusable by scripts.""" from __future__ import annotations
-from pywikibot.specialbots._unlink import BaseUnlinkBot, InteractiveUnlink +from pywikibot.specialbots._unlink import ( + BaseUnlinkBot, + EditReplacementError, + InteractiveUnlink, +) from pywikibot.specialbots._upload import UploadRobot
__all__ = ( 'BaseUnlinkBot', + 'EditReplacementError', 'InteractiveUnlink', 'UploadRobot', ) diff --git a/tests/__init__.py b/tests/__init__.py index 406b694..57bbcf8 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -157,6 +157,7 @@ 'tools_threading', 'ui', 'ui_options', + 'unlinkbot', 'upload', 'uploadbot', 'user', diff --git a/tests/unlinkbot_tests.py b/tests/unlinkbot_tests.py new file mode 100755 index 0000000..9352800 --- /dev/null +++ b/tests/unlinkbot_tests.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python3 +# +# (C) Pywikibot team, 2014-2026 +# +# Distributed under the terms of the MIT license. +# +"""Special BaseUnlinkBot test.""" +from __future__ import annotations + +import unittest +from contextlib import suppress + +from pywikibot.specialbots import BaseUnlinkBot, EditReplacementError +from tests.aspects import TestCase + + +class TestDryUnlinkbot(TestCase): + + """Dry tests UploadRobot.""" + + net = False + + def test_unlink_bot(self) -> None: + """Test UploadRobot attributes and methods.""" + bot = BaseUnlinkBot(always=True, namespaces=[0, 2]) + self.assertTrue(bot.opt.always) + self.assertEqual(bot.opt.namespaces, [0, 2]) # ignore_warning + + +class TestChoiceOptions(TestCase): + + """Test cases for unlink bot_choice Options.""" + + net = False + + def test_edit_replacement_excepton(self) -> None: + """Test ChoiceException.""" + option = EditReplacementError() + self.assertTrue(option.stop) + self.assertEqual(option.result('*'), option) + with self.assertRaises(EditReplacementError): + raise EditReplacementError + + +if __name__ == '__main__': + with suppress(SystemExit): + unittest.main()
pywikibot-commits@lists.wikimedia.org