jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/697437 )

Change subject: [tests] Do not call pywikibot.Site() if 
aspects.DisableSiteMixin is used
......................................................................

[tests] Do not call pywikibot.Site() if aspects.DisableSiteMixin is used

Bug: T284018
Change-Id: I291100ec2f6a552e0f1c4f793e28dd8290bf1d97
---
M pywikibot/bot.py
M tests/aspects.py
2 files changed, 8 insertions(+), 4 deletions(-)

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



diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 216b39d..47422ae 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -349,10 +349,13 @@

     # if user has enabled file logging, configure file handler
     if module_name in config.log or '*' in config.log:
-        # get PID
-        throttle = pywikibot.Site().throttle  # initialize a Throttle object
-        pid = throttle.get_pid(module_name)  # get the global PID if needed
-        pid = str(pid) + '-' if pid > 1 else ''
+        if pywikibot.Site.__doc__ == 'TEST':  # set by aspects.DisableSiteMixin
+            pid = ''
+        else:
+            # get PID
+            throttle = pywikibot.Site().throttle  # initialize a Throttle obj
+            pid = throttle.get_pid(module_name)  # get the global PID if needed
+            pid = str(pid) + '-' if pid > 1 else ''

         if config.logfilename:
             # keep config.logfilename unchanged
diff --git a/tests/aspects.py b/tests/aspects.py
index f9da3cc..4c819fb 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -327,6 +327,7 @@
         self.old_Site_lookup_method = pywikibot.Site
         pywikibot.Site = lambda *args: self.fail(
             '{}: Site() not permitted'.format(self.__class__.__name__))
+        pywikibot.Site.__doc__ = 'TEST'

         super().setUp()


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

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I291100ec2f6a552e0f1c4f793e28dd8290bf1d97
Gerrit-Change-Number: 697437
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to