jenkins-bot has submitted this change and it was merged.
Change subject: [FIX] Tests: Use any image available on the server ......................................................................
[FIX] Tests: Use any image available on the server
Change-Id: I05c5eaeca45e0909dd60e900c3928616986c3b23 --- M tests/site_tests.py 1 file changed, 23 insertions(+), 6 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/site_tests.py b/tests/site_tests.py index 26f514e..fba6177 100644 --- a/tests/site_tests.py +++ b/tests/site_tests.py @@ -588,8 +588,17 @@ def testImageusage(self): """Test the site.imageusage() method""" mysite = self.get_site() - mainpage = self.get_mainpage() - imagepage = next(iter(mainpage.imagelinks())) # 1st image on main page + # Find a page which uses an image, so we can test imageusage + # If there are no images included in pages it'll skip this test + for page in mysite.allpages(filterredir=False): + try: + imagepage = next(iter(page.imagelinks())) # 1st image of page + except StopIteration: + pass + else: + break + else: + raise unittest.SkipTest("No images on site {0!r}".format(mysite))
iu = list(mysite.imageusage(imagepage, total=10)) self.assertLessEqual(len(iu), 10) @@ -652,7 +661,12 @@ """Test the site.recentchanges() method""" mysite = self.get_site() mainpage = self.get_mainpage() - imagepage = next(iter(mainpage.imagelinks())) + try: + # 1st image on main page + imagepage = next(iter(mysite.allimages())) + except StopIteration: + print("No images on site {0!r}".format(mysite)) + imagepage = None rc = list(mysite.recentchanges(total=10)) self.assertLessEqual(len(rc), 10) self.assertTrue(all(isinstance(change, dict) @@ -702,12 +716,15 @@ self.assertIn(mysite.ns_index(prefix), [6, 7]) self.assertIn(change["ns"], [6, 7]) if LV(mysite.version()) <= LV("1.14"): - for change in mysite.recentchanges(pagelist=[mainpage, imagepage], + pagelist = [mainpage] + if imagepage: + pagelist += [imagepage] + titlelist = set(page.title() for page in pagelist) + for change in mysite.recentchanges(pagelist=pagelist, total=5): self.assertIsInstance(change, dict) self.assertIn("title", change) - self.assertIn(change["title"], (mainpage.title(), - imagepage.title())) + self.assertIn(change["title"], titlelist) for typ in ("edit", "new", "log"): for change in mysite.recentchanges(changetype=typ, total=5): self.assertIsInstance(change, dict)