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()
pywikibot-commits@lists.wikimedia.org