jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1004727?usp=email )
Change subject: [doc] Update environment variables in tests documentation
......................................................................
[doc] Update environment variables in tests documentation
Add description for PYWIKIBOT_TEST_NO_RC and PYWIKIBOT_TEST_QUIET
Change-Id: I49e61b30d4c83473a35e5344afd9cdc1e28b7792
---
M tests/README.rst
1 file changed, 25 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/README.rst b/tests/README.rst
index bff07ea..e6880d0 100644
--- a/tests/README.rst
+++ b/tests/README.rst
@@ -116,15 +116,28 @@
.. note:: test names must be given without subsequent ``_tests``.
+**PYWIKIBOT_TEST_NO_RC**
+ This environment variable disables recent changes tests and can be used to
+ speed up tests. GitHub actions enables this setting for that purpose::
+
+ PYWIKIBOT_TEST_NO_RC=1
+
**PYWIKIBOT_TEST_OAUTH**
This environment variable holds the Oauth token. It is set by
``oauth_tests-ci.yml`` CI config file and is solely used by
:mod:`tests.oauth_tests`. You can use it for your private tests. The
- environment variabke must contain consumer key and secret and access
+ environment variable must contain consumer key and secret and access
key and secret delimited by ``:`` as::
PYWIKIBOT_TEST_OAUTH=consumer_key:consumer_secret:access_key:access:secret
+**PYWIKIBOT_TEST_QUIET**
+ This environment variable can be set for quit mode. It prevents output by
+ test package, i.e. 'max_retries reduced from x to y'. It is used be the
+ :func:`tests.utils.execute` test runner. To enable it for other tests use::
+
+ PYWIKIBOT_TEST_QUIET=1
+
**PYWIKIBOT_TEST_RUNNING**
This environment variable skips tests instead of raising
:exc:`exceptions.MaxlagTimeoutError` when maximum retries attempted due to
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1004727?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I49e61b30d4c83473a35e5344afd9cdc1e28b7792
Gerrit-Change-Number: 1004727
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1004659?usp=email )
Change subject: [tests] Show site if skipping tests due to missing rights
......................................................................
[tests] Show site if skipping tests due to missing rights
Change-Id: I2541bdc05e98c2fe8fb563d9486e4797ebcdef79
---
M tests/aspects.py
1 file changed, 12 insertions(+), 3 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/tests/aspects.py b/tests/aspects.py
index 4c3d1fb..4ae285e 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -675,9 +675,9 @@
for right in cls.rights.split(','):
if not site.has_right(right):
- raise unittest.SkipTest('User "{}" does not have required '
- 'user right "{}"'
- .format(site.user(), right))
+ raise unittest.SkipTest(
+ f'User "{site.user()}" does not have required user '
+ f'right "{right}" on site "{site}"')
class MetaTestCaseClass(type):
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1004659?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I2541bdc05e98c2fe8fb563d9486e4797ebcdef79
Gerrit-Change-Number: 1004659
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1000779?usp=email )
Change subject: [IMPR] Only delegate site methods to public Family methods
......................................................................
[IMPR] Only delegate site methods to public Family methods
BaseSite.__getattr__() rewritten.
Undefined methods calls are delegated to the Family object.
No longer delegate private methods like _get_cr_templates or
_hostname. Also do not delegate static methods or other methods
which does not have 'code' as first parameter.
Change-Id: Ibca93fbbd14b3a901d816afca9db8cbc9ff4dba6
---
M pywikibot/site/_basesite.py
1 file changed, 39 insertions(+), 14 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/site/_basesite.py b/pywikibot/site/_basesite.py
index 813cf91..2eaa581 100644
--- a/pywikibot/site/_basesite.py
+++ b/pywikibot/site/_basesite.py
@@ -1,12 +1,13 @@
"""Objects with site methods independent of the communication interface."""
#
-# (C) Pywikibot team, 2008-2023
+# (C) Pywikibot team, 2008-2024
#
# Distributed under the terms of the MIT license.
#
from __future__ import annotations
import functools
+import inspect
import re
import threading
from warnings import warn
@@ -194,19 +195,27 @@
"""Return the username used for the site."""
return self._username
- def __getattr__(self, attr):
- """Delegate undefined methods calls to the Family object."""
- try:
- method = getattr(self.family, attr)
- if not callable(method):
- raise AttributeError
- f = functools.partial(method, self.code)
- if hasattr(method, '__doc__'):
- f.__doc__ = method.__doc__
- return f
- except AttributeError:
- raise AttributeError(f'{type(self).__name__} instance has no '
- f'attribute {attr!r}') from None
+ def __getattr__(self, name: str):
+ """Delegate undefined methods calls to the Family object.
+
+ .. versionchanged:: 9.0
+ Only delegate to public Family methods which have ``code`` as
+ first parameter.
+ """
+ if not name.startswith('_'):
+ obj = getattr(self.family, name, None)
+ if inspect.ismethod(obj):
+ params = inspect.signature(obj).parameters
+ if params:
+ parameter = next(iter(params))
+ if parameter == 'code':
+ method = functools.partial(obj, self.code)
+ if hasattr(obj, '__doc__'):
+ method.__doc__ = obj.__doc__
+ return method
+
+ raise AttributeError(f'{type(self).__name__} instance has no '
+ f'attribute {name!r}') from None
def __str__(self) -> str:
"""Return string representing this Site's name and code."""
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1000779?usp=email
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ibca93fbbd14b3a901d816afca9db8cbc9ff4dba6
Gerrit-Change-Number: 1000779
Gerrit-PatchSet: 6
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged