jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/345373 )
Change subject: category_bot_tests: Temporarily set a fake username for BaseSite ......................................................................
category_bot_tests: Temporarily set a fake username for BaseSite
Temporarily patch BaseSite.username method to make it return a fake username. This will help to circumvent NoUsername error during the initialization of CategoryMoveRobot if there is no user name set for wikibase.
Bug: T161692 Change-Id: I08350274a6917496ab9b1850571f216428f6b164 --- M tests/category_bot_tests.py 1 file changed, 12 insertions(+), 0 deletions(-)
Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
diff --git a/tests/category_bot_tests.py b/tests/category_bot_tests.py index fd6d6ff..29dad8e 100644 --- a/tests/category_bot_tests.py +++ b/tests/category_bot_tests.py @@ -9,11 +9,23 @@
__version__ = '$Id$'
+try: + from unittest.mock import patch, Mock +except ImportError: + from mock import patch, Mock + +from pywikibot import BaseSite + from scripts.category import CategoryMoveRobot
from tests.aspects import unittest, DefaultSiteTestCase
+MOCKED_USERNAME = Mock(return_value='FakeUsername') + + +# Temporarily set a username to circumvent NoUsername error; T161692 +@patch.object(BaseSite, 'username', new=MOCKED_USERNAME) class CfdActions(DefaultSiteTestCase):
"""Test CFD (Categories for deletion) actions."""
pywikibot-commits@lists.wikimedia.org