Xqt has submitted this change and it was merged.
Change subject: Wrap api search test in skip wrapper
......................................................................
Wrap api search test in skip wrapper
If the search method returns an timeout, such as in [1], the build fails. This
changes the behavior, and marks the test as 'skipped'. Non-timeouts will
still cause the build to fail.
[1]
https://travis-ci.org/wikimedia/pywikibot-core/builds/11205092
Change-Id: I59b2c576e156c3896c7b1743c7d046af7386834b
---
M tests/site_tests.py
1 file changed, 23 insertions(+), 19 deletions(-)
Approvals:
Xqt: Looks good to me, approved
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 6d41c98..d9811bb 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -686,25 +686,29 @@
def testSearch(self):
"""Test the site.search() method"""
-
- se = list(mysite.search("wiki", total=10))
- self.assertTrue(len(se) <= 10)
- self.assertTrue(all(isinstance(hit, pywikibot.Page)
- for hit in se))
- self.assertTrue(all(hit.namespace() == 0 for hit in se))
- for hit in mysite.search("common", namespaces=4, total=5):
- self.assertType(hit, pywikibot.Page)
- self.assertEqual(hit.namespace(), 4)
- for hit in mysite.search("word", namespaces=[5, 6, 7], total=5):
- self.assertType(hit, pywikibot.Page)
- self.assertTrue(hit.namespace() in [5, 6, 7])
- for hit in mysite.search("another", namespaces="8|9|10",
total=5):
- self.assertType(hit, pywikibot.Page)
- self.assertTrue(hit.namespace() in [8, 9, 10])
- for hit in mysite.search("wiki", namespaces=0, total=10,
- getredirects=True):
- self.assertType(hit, pywikibot.Page)
- self.assertEqual(hit.namespace(), 0)
+ try:
+ se = list(mysite.search("wiki", total=10))
+ self.assertTrue(len(se) <= 10)
+ self.assertTrue(all(isinstance(hit, pywikibot.Page)
+ for hit in se))
+ self.assertTrue(all(hit.namespace() == 0 for hit in se))
+ for hit in mysite.search("common", namespaces=4, total=5):
+ self.assertType(hit, pywikibot.Page)
+ self.assertEqual(hit.namespace(), 4)
+ for hit in mysite.search("word", namespaces=[5, 6, 7], total=5):
+ self.assertType(hit, pywikibot.Page)
+ self.assertTrue(hit.namespace() in [5, 6, 7])
+ for hit in mysite.search("another", namespaces="8|9|10",
total=5):
+ self.assertType(hit, pywikibot.Page)
+ self.assertTrue(hit.namespace() in [8, 9, 10])
+ for hit in mysite.search("wiki", namespaces=0, total=10,
+ getredirects=True):
+ self.assertType(hit, pywikibot.Page)
+ self.assertEqual(hit.namespace(), 0)
+ except pywikibot.data.api.APIError as e:
+ if e.code == "gsrsearch-error" and "timed out" in
e.info:
+ raise unittest.SkipTest("gsrsearch returned timeout on site:
%r" % e)
+ raise
def testUsercontribs(self):
"""Test the site.usercontribs() method"""
--
To view, visit
https://gerrit.wikimedia.org/r/83669
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I59b2c576e156c3896c7b1743c7d046af7386834b
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot