jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1317658?usp=email )
Change subject: Add PYWIKIBOT_TEST_DEFAULT_ONLY environment variable
......................................................................
Add PYWIKIBOT_TEST_DEFAULT_ONLY environment variable
If set, only tests derived from DefaultSiteTestCase are run.
Bug: T433204
Change-Id: I58fbcfb74dc7c270bfd3722183797d5ff1910a47
---
M tests/README.rst
M tests/aspects.py
2 files changed, 16 insertions(+), 0 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/tests/README.rst b/tests/README.rst
index 905c1ae..3875a61 100644
--- a/tests/README.rst
+++ b/tests/README.rst
@@ -83,6 +83,16 @@
Environment variables
=====================
+**PYWIKIBOT_TEST_DEFAULT_ONLY**
+ Only run tests which use the configured default site, i.e. tests derived
+ from :class:`DefaultSiteTestCase<tests.aspects.DefaultSiteTestCase>`.
+ This can be used to skip tests with fixed ``family``/``code`` values in
+ redundant CI jobs where only the default site differs. To enable it, set::
+
+ PYWIKIBOT_TEST_DEFAULT_ONLY=1
+
+ .. version-added:: 11.7
+
**PYWIKIBOT_TEST_LOGOUT**
Used when a test is logging out the test user. This environment variable
enables :source:`tests/site_login_logout_tests`. The environment setting is
diff --git a/tests/aspects.py b/tests/aspects.py
index 3b4efea..e892af8 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -1060,6 +1060,8 @@
"""Run tests on pre-defined sites."""
+ is_defaultsite_test = False
+
@classmethod
def setUpClass(cls) -> None:
"""Set up the test class.
@@ -1068,6 +1070,9 @@
has declared are needed.
"""
super().setUpClass()
+ if (os.getenv('PYWIKIBOT_TEST_DEFAULT_ONLY', '0') == '1'
+ and not cls.is_defaultsite_test):
+ raise unittest.SkipTest('Only default site tests are enabled.')
if not hasattr(cls, 'sites'):
return
@@ -1270,6 +1275,7 @@
family = config.family
code = config.mylang
+ is_defaultsite_test = True
@classmethod
def override_default_site(cls, site) -> None:
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1317658?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: I58fbcfb74dc7c270bfd3722183797d5ff1910a47
Gerrit-Change-Number: 1317658
Gerrit-PatchSet: 1
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]