jenkins-bot has submitted this change and it was merged.

Change subject: Wikibase pages can be redirects
......................................................................


Wikibase pages can be redirects

some tests have been added

Change-Id: I9898a4a6312ca5c2b2dd6d02d177b0ba4611f052
---
M pywikibot/page.py
M tests/wikibase_tests.py
2 files changed, 16 insertions(+), 1 deletion(-)

Approvals:
  John Vandenberg: Looks good to me, approved
  XZise: Looks good to me, but someone else must approve
  jenkins-bot: Verified



diff --git a/pywikibot/page.py b/pywikibot/page.py
index e77b23e..87791be 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -2616,7 +2616,6 @@
             raise TypeError("site must be a pywikibot.site.DataSite object")
         Page.__init__(self, site, title, **kwargs)
         self.repo = self.site
-        self._isredir = False  # Wikibase pages cannot be a redirect
 
     def title(self, **kwargs):
         """ Page title.
diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py
index fafb515..d629e7e 100644
--- a/tests/wikibase_tests.py
+++ b/tests/wikibase_tests.py
@@ -371,6 +371,22 @@
         self.assertRaisesRegexp(pywikibot.NoPage, 'Test page', item.get)
 
 
+class TestRedirects(PywikibotTestCase):
+
+    """Test redirect and non-redirect items."""
+
+    def test_normal_item(self):
+        item = pywikibot.ItemPage(wikidata, 'Q1')
+        self.assertFalse(item.isRedirectPage())
+        self.assertRaises(pywikibot.IsNotRedirectPage, item.getRedirectTarget)
+
+    def test_redirect_item(self):
+        item = pywikibot.ItemPage(wikidata, 'Q10008448')
+        target = pywikibot.ItemPage(wikidata, 'Q8422626')
+        self.assertTrue(item.isRedirectPage())
+        self.assertEqual(item.getRedirectTarget(), target)
+
+
 class TestPropertyPage(PywikibotTestCase):
 
     def test_property_empty_property(self):

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I9898a4a6312ca5c2b2dd6d02d177b0ba4611f052
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ricordisamoa <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: Ricordisamoa <[email protected]>
Gerrit-Reviewer: XZise <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to