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

Change subject: Test: Extract error message for T408721
......................................................................

Test: Extract error message for T408721

Change-Id: Icfbbc1b47290a3c77c896691ca90f3692c5c5371
---
M pywikibot/login.py
1 file changed, 13 insertions(+), 3 deletions(-)

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




diff --git a/pywikibot/login.py b/pywikibot/login.py
index 94650e9..2d9b9d9 100644
--- a/pywikibot/login.py
+++ b/pywikibot/login.py
@@ -34,6 +34,9 @@
     mwoauth = e


+TEST_RUNNING = os.environ.get('PYWIKIBOT_TEST_RUNNING', '0') == '1'
+
+
 class _PasswordFileWarning(UserWarning):

     """The format of password file is incorrect."""
@@ -234,9 +237,8 @@
             password_path = Path(config.password_file)

         # ignore this check when running tests
-        if os.environ.get('PYWIKIBOT_TEST_RUNNING', '0') == '0' \
-           and (not password_path.is_file(**params)
-                or password_path.is_symlink()):
+        if not TEST_RUNNING and (not password_path.is_file(**params)
+                                 or password_path.is_symlink()):
             raise FileNotFoundError(
                 f'Password file {password_path.name} does not exist in '
                 f'{password_path.parent}'
@@ -622,6 +624,8 @@
                 pywikibot.error(e)
                 if retry:
                     return self.login(retry=True, force=force)
+                if TEST_RUNNING:
+                    print('>>> login:', e)  # noqa: T201
                 return False
         else:
             pywikibot.info(f'Logged in to {self.site} via consumer '
@@ -666,6 +670,8 @@
         """
         if self.access_token is None:
             pywikibot.error('Access token not set')
+            if TEST_RUNNING:
+                print('>>> identity: Access token not set')  # noqa: T201
             return None

         consumer_token = mwoauth.ConsumerToken(*self.consumer_token)
@@ -677,7 +683,11 @@
                                         leeway=30.0)
         except Exception as e:
             pywikibot.error(e)
+            if TEST_RUNNING:
+                print('<<< identity:', e)  # noqa: T201
         else:
+            if TEST_RUNNING:
+                print('<<< identity =', identity)  # noqa: T201
             return identity

         return None

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1199990?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: Icfbbc1b47290a3c77c896691ca90f3692c5c5371
Gerrit-Change-Number: 1199990
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