jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/370609 )
Change subject: [bugfix] Test page_image() for older mw version and missing extension ......................................................................
[bugfix] Test page_image() for older mw version and missing extension
Bug: T172770 Change-Id: Idb3f66df995ad3b20710ef2a3358d2c066e9663b --- M tests/page_tests.py 1 file changed, 12 insertions(+), 3 deletions(-)
Approvals: Strainu: Looks good to me, approved jenkins-bot: Verified
diff --git a/tests/page_tests.py b/tests/page_tests.py index d6698ce..c6d659c 100644 --- a/tests/page_tests.py +++ b/tests/page_tests.py @@ -559,9 +559,18 @@ site = self.get_site() mainpage = self.get_mainpage() image = pywikibot.FilePage(site, 'File:Jean-Léon Gérôme 003.jpg') - self.assertIsInstance(mainpage.page_image(), pywikibot.FilePage) - # for file pages, the API should return the file itself - self.assertEqual(image.page_image(), image) + + if MediaWikiVersion(site.version()) < MediaWikiVersion('1.20'): + self.assertRaises(NotImplementedError, mainpage.page_image) + elif site.has_extension('PageImages'): + self.assertIsInstance(mainpage.page_image(), pywikibot.FilePage) + # for file pages, the API should return the file itself + self.assertEqual(image.page_image(), image) + else: + self.assertRaises(pywikibot.UnknownExtension, + 'Method "loadpageimage" is not implemented ' + 'without the extension PageImages', + mainpage.page_image)
class TestPageDeprecation(DefaultSiteTestCase, DeprecationTestCase):
pywikibot-commits@lists.wikimedia.org