jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/362927 )
Change subject: [bugfix] Fix TestLazyLoginNotExistUsername test for Stewardwiki
......................................................................
[bugfix] Fix TestLazyLoginNotExistUsername test for Stewardwiki
login with not existing username is denied with
login result "Failed" and the reason
"The supplied credentials could not be authenticated".
Use this result to raise a NoUsername exception as expected.
Bug: T169458
Change-Id: I81f62ecaf6ee57b12d0878e7da2cab9a5a63d996
---
M pywikibot/data/api.py
M pywikibot/login.py
2 files changed, 7 insertions(+), 2 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 4c28951..acb0d19 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -3076,7 +3076,8 @@
break
else:
break
- raise APIError(code=login_result["login"]["result"],
info="")
+ info = login_result['login'].get('reason', '')
+ raise APIError(code=login_result['login']['result'], info=info)
def storecookiedata(self, data):
"""Ignore data; cookies are set by threadedhttp
module."""
diff --git a/pywikibot/login.py b/pywikibot/login.py
index 01ebf6b..fefbda7 100644
--- a/pywikibot/login.py
+++ b/pywikibot/login.py
@@ -3,7 +3,7 @@
"""Library to log the bot in to a wiki account."""
#
# (C) Rob W.W. Hooft, 2003
-# (C) Pywikibot team, 2003-2016
+# (C) Pywikibot team, 2003-2017
#
# Distributed under the terms of the MIT license.
#
@@ -320,6 +320,10 @@
raise NoUsername(
'Username "{0}" does not have read permissions on
'
'{1}'.format(self.login_name, self.site))
+ elif e.code == 'Failed':
+ raise NoUsername(
+ 'Username "{0}" does not have read permissions on
'
+ '{1}\n.{2}'.format(self.login_name, self.site, e.info))
# TODO: investigate other unhandled API codes (bug T75539)
if retry:
self.password = None
--
To view, visit
https://gerrit.wikimedia.org/r/362927
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I81f62ecaf6ee57b12d0878e7da2cab9a5a63d996
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Magul <tomasz.magulski(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Multichill <maarten(a)mdammers.nl>
Gerrit-Reviewer: jenkins-bot <>