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

Change subject: IMPR: add access_token.setter to OauthLoginManager
......................................................................

IMPR: add access_token.setter to OauthLoginManager

Also add representation string for LoginManager

Change-Id: I4ff8178b7083ad533f746119a5351334025d7c1b
---
M pywikibot/login.py
M tests/oauth_tests.py
2 files changed, 21 insertions(+), 2 deletions(-)

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




diff --git a/pywikibot/login.py b/pywikibot/login.py
index 1a714e1..b670c59 100644
--- a/pywikibot/login.py
+++ b/pywikibot/login.py
@@ -112,6 +112,13 @@
         if getattr(config, 'password_file', ''):
             self.readPassword()

+    def __repr__(self):
+        """Return representation string for LoginManager.
+
+        ..versionadded:: 10.0
+        """
+        return f'{type(self).__name__}(user={self.username!r})'
+
     def check_user_exists(self) -> None:
         """Check that the username exists on the site.

@@ -584,12 +591,24 @@

     @property
     def access_token(self) -> tuple[str, str] | None:
-        """Return OAuth access key token and secret token.
+        """OAuth access key token and secret token.

         .. seealso:: :api:`Tokens`
+
+        :getter: Return OAuth access key token and secret token.
+        :setter: Add OAuth access key token and secret token.
+            Implemented to discard user interaction token fetching,
+            usually for tests.
+
+            .. versionadded:: 10.0
         """
         return self._access_token

+    @access_token.setter
+    def access_token(self, token: tuple[str, str]) -> None:
+        """Add OAuth access key token and secret token."""
+        self._access_token = token
+
     @property
     def identity(self) -> dict[str, Any] | None:
         """Get identifying information about a user via an authorized token.
diff --git a/tests/oauth_tests.py b/tests/oauth_tests.py
index bbdb8e3..fa7310a 100755
--- a/tests/oauth_tests.py
+++ b/tests/oauth_tests.py
@@ -101,7 +101,7 @@
                                           site=self.site,
                                           user=self.consumer_token[0])
         # Set access token directly, discard user interaction token fetching
-        login_manager._access_token = self.access_token
+        login_manager.access_token = self.access_token
         return login_manager

     def test_login(self):

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