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

Change subject: tests: Mock APISite.login in deletionbot_tests.py
......................................................................

tests: Mock APISite.login in deletionbot_tests.py

Using a site tries to login and this may fail sometimes but it is not
necessary for this tests. Therefore mock the APISite.login

Bug: T364841
Bug: T396132
Change-Id: I08440a6c6eb5898d0c4c3c6473bd8bdeea43b73a
---
M tests/deletionbot_tests.py
1 file changed, 12 insertions(+), 7 deletions(-)

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




diff --git a/tests/deletionbot_tests.py b/tests/deletionbot_tests.py
index eaa40c6..325d02a 100755
--- a/tests/deletionbot_tests.py
+++ b/tests/deletionbot_tests.py
@@ -9,10 +9,11 @@

 import unittest
 from contextlib import suppress
+from unittest.mock import patch

 import pywikibot
 from scripts import delete
-from tests.aspects import ScriptMainTestCase
+from tests.aspects import DefaultSiteTestCase, ScriptMainTestCase
 from tests.utils import empty_sites


@@ -89,19 +90,23 @@
             'Pywikibot deletion test.')


-class TestDeletionBot(ScriptMainTestCase):
+class TestDeletionBot(DefaultSiteTestCase):

     """Test deletionbot with patching to make it non-write."""

-    family = 'wikipedia'
-    code = 'test'
-
-    cached = True
-    login = True
+    net = False

     delete_args = []
     undelete_args = []

+    @classmethod
+    def setUpClass(cls):
+        """Patch APISite.login."""
+        patcher = patch.object(pywikibot.site.APISite, 'login')
+        cls.addClassCleanup(patcher.stop)
+        patcher.start()
+        super().setUpClass()
+
     def setUp(self):
         """Set up unit test."""
         self._original_delete = pywikibot.Page.delete

-- 
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1154244?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: I08440a6c6eb5898d0c4c3c6473bd8bdeea43b73a
Gerrit-Change-Number: 1154244
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <[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]

Reply via email to