jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/571695 )
Change subject: [tests] Show additional informations with "urlshortener-blocked" APIError ......................................................................
[tests] Show additional informations with "urlshortener-blocked" APIError
- add site and user to the result['error'] dict in case of T244062 - if not logged in, site.user() is None; show the IP in that case - print "other" information in separate lines with APIError
Bug: T244062 Change-Id: Ia4399c33e751922f105e17968419dd4bb69d1246 --- M pywikibot/data/api.py 1 file changed, 12 insertions(+), 3 deletions(-)
Approvals: Dvorapa: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py index 8cccf44..bd169d9 100644 --- a/pywikibot/data/api.py +++ b/pywikibot/data/api.py @@ -120,11 +120,11 @@ def __str__(self): """Return a string representation.""" if self.other: - return '{0}: {1} [{2}]'.format( + return '{0}: {1}\n[{2}]'.format( self.code, self.info, - '; '.join( - '{0}:{1}'.format(key, val) + ';\n '.join( + '{0}: {1}'.format(key, val) for key, val in self.other.items()))
return '{0}: {1}'.format(self.code, self.info) @@ -2069,6 +2069,15 @@ self.wait() continue
+ if code == 'urlshortener-blocked': # T244062 + # add additional informations to result['error'] + result['error']['current site'] = self.site + if self.site.user(): + result['error']['current user'] = self.site.user() + else: # not logged in; show the IP + si = self.site.siteinfo + result['error']['current user'] = si['name'] + # raise error try: # Due to bug T66958, Page's repr may return non ASCII bytes
pywikibot-commits@lists.wikimedia.org