jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/569277 )
Change subject: [tests] skip tests if they failed due to maxlag timeout
......................................................................
[tests] skip tests if they failed due to maxlag timeout
- Introduce a new MaxlagTimeoutError
- Use this exception when maximum retries attempted
due to maxlag without success
- If tests are running raise unittest.SkipTest instead
- Add new environ variable PYWIKIBOT_TESTS_RUNNING
which is set to 1 within .travis.yml and .appveyor.yml
Bug: T242081
Change-Id: Ica615acd2a3da0f48342b5a0b2442ae185d6028d
---
M .appveyor.yml
M .travis.yml
M pywikibot/data/api.py
M pywikibot/exceptions.py
4 files changed, 16 insertions(+), 3 deletions(-)
Approvals:
Dvorapa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/.appveyor.yml b/.appveyor.yml
index d98b541..d4e6dd1 100644
--- a/.appveyor.yml
+++ b/.appveyor.yml
@@ -13,6 +13,7 @@
PYSETUP_TEST_EXTRAS: "1"
PYSETUP_TEST_NO_UI: "1"
+ PYWIKIBOT_TESTS_RUNNING: "1"
matrix:
diff --git a/.travis.yml b/.travis.yml
index 00b7242..0845827 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -121,6 +121,7 @@
global:
- TEST_TIMEOUT=300
- PYWIKIBOT_NO_L10N_TESTS=1
+ - PYWIKIBOT_TESTS_RUNNING=1
matrix:
- LANGUAGE=en FAMILY=wikipedia PYWIKIBOT_TEST_PROD_ONLY=1
diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index d65c260..cde1dd5 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -35,7 +35,7 @@
from pywikibot.comms import http
from pywikibot.exceptions import (
Server504Error, Server414Error, FatalServerError, NoUsername,
- Error, TimeoutError, InvalidTitle, UnsupportedPage
+ Error, TimeoutError, MaxlagTimeoutError, InvalidTitle, UnsupportedPage
)
from pywikibot.tools import (
deprecated, itergroup, PY2, PYTHON_VERSION,
@@ -2097,8 +2097,12 @@
except TypeError:
raise RuntimeError(result)
- raise TimeoutError(
- 'Maximum retries attempted due to maxlag without success.')
+ msg = 'Maximum retries attempted due to maxlag without success.'
+ if os.environ.get('PYWIKIBOT_TESTS_RUNNING', '0') ==
'1':
+ import unittest
+ raise unittest.SkipTest(msg)
+
+ raise MaxlagTimeoutError(msg)
def wait(self):
"""Determine how long to wait after a failed
request."""
diff --git a/pywikibot/exceptions.py b/pywikibot/exceptions.py
index 1be8d9a..050846e 100644
--- a/pywikibot/exceptions.py
+++ b/pywikibot/exceptions.py
@@ -602,6 +602,13 @@
pass
+class MaxlagTimeoutError(TimeoutError):
+
+ """Request failed with a maxlag timeout error."""
+
+ pass
+
+
@__deprecated(since='20141214')
class DeprecatedPageNotFoundError(Error):
--
To view, visit
https://gerrit.wikimedia.org/r/569277
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ica615acd2a3da0f48342b5a0b2442ae185d6028d
Gerrit-Change-Number: 569277
Gerrit-PatchSet: 12
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: D3r1ck01 <xsavitar.wiki(a)aol.com>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: Huji <huji.huji(a)gmail.com>
Gerrit-Reviewer: JJMC89 <JJMC89.Wikimedia(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <Ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm(a)member.fsf.org>
Gerrit-Reviewer: Matěj Suchánek <matejsuchanek97(a)gmail.com>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: XZise <CommodoreFabianus(a)gmx.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)