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):

-- 
To view, visit https://gerrit.wikimedia.org/r/370609
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Idb3f66df995ad3b20710ef2a3358d2c066e9663b
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Xqt <i...@gno.de>
Gerrit-Reviewer: John Vandenberg <jay...@gmail.com>
Gerrit-Reviewer: Magul <tomasz.magul...@gmail.com>
Gerrit-Reviewer: Strainu <w...@strainu.ro>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
Pywikibot-commits mailing list
Pywikibot-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to