jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/510469 )
Change subject: [tests] Enable basepage_tests for flow ......................................................................
[tests] Enable basepage_tests for flow
TestLoadRevisionsCaching.test_page_text was deactivated due to T107537 because FlowPage.get(get_redirect=True) raises NotImplementedError
Bug: T107537 Change-Id: I2e5575e163a4e6047695fdc6d9b4ab29fde5af8e --- M pywikibot/flow.py M tests/basepage_tests.py M tests/flow_tests.py 3 files changed, 22 insertions(+), 19 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/flow.py b/pywikibot/flow.py index 239e791..29c7579 100644 --- a/pywikibot/flow.py +++ b/pywikibot/flow.py @@ -62,7 +62,9 @@ def get(self, force=False, get_redirect=False): """Get the page's content.""" if get_redirect or force: - raise NotImplementedError + raise NotImplementedError( + "Neither 'force' nor 'get_redirect' parameter is implemented " + 'in {}.get()'.format(self.__class__.__name__))
# TODO: Return more useful data return self._data diff --git a/tests/basepage_tests.py b/tests/basepage_tests.py index bd2460f..b072249 100644 --- a/tests/basepage_tests.py +++ b/tests/basepage_tests.py @@ -5,13 +5,11 @@ # # Distributed under the terms of the MIT license. # -from __future__ import absolute_import, division, unicode_literals +from contextlib import suppress
from pywikibot.page import BasePage
-from tests.aspects import ( - unittest, TestCase, -) +from tests.aspects import unittest, TestCase
class BasePageTestBase(TestCase): @@ -22,7 +20,7 @@
def setUp(self): """Set up test.""" - super(BasePageTestBase, self).setUp() + super().setUp() assert self._page, 'setUp() must create an empty BasePage in _page' assert isinstance(self._page, BasePage)
@@ -42,10 +40,10 @@
def setUp(self): """Set up test.""" - super(BasePageLoadRevisionsCachingTestBase, self).setUp() + super().setUp() assert self.cached is False, 'Tests do not support caching'
- def _test_page_text(self): + def _test_page_text(self, get_text=True): """Test site.loadrevisions() with .text.""" page = self._page
@@ -89,16 +87,23 @@ loadrevisions = self.site.loadrevisions try: self.site.loadrevisions = None - loaded_text = page.text + if get_text: + loaded_text = page.text + else: # T107537 + with self.assertRaises(NotImplementedError): + page.text + loaded_text = '' self.assertIsNotNone(loaded_text) self.assertFalse(hasattr(page, '_text')) page.text = custom_text - self.assertEqual(page.get(), loaded_text) + if get_text: + self.assertEqual(page.get(), loaded_text) self.assertEqual(page._text, custom_text) self.assertEqual(page.text, page._text) del page.text self.assertFalse(hasattr(page, '_text')) - self.assertEqual(page.text, loaded_text) + if get_text: + self.assertEqual(page.text, loaded_text) finally: self.site.loadrevisions = loadrevisions
@@ -136,7 +141,5 @@
if __name__ == '__main__': # pragma: no cover - try: + with suppress(SystemExit): unittest.main() - except SystemExit: - pass diff --git a/tests/flow_tests.py b/tests/flow_tests.py index 60f644f..fc48680 100644 --- a/tests/flow_tests.py +++ b/tests/flow_tests.py @@ -11,9 +11,8 @@ from pywikibot.flow import Board, Topic, Post
from tests import unittest -from tests.aspects import ( - TestCase, -) + +from tests.aspects import TestCase from tests.basepage_tests import ( BasePageMethodsTestBase, BasePageLoadRevisionsCachingTestBase, @@ -81,8 +80,7 @@
def test_page_text(self): """Test site.loadrevisions() with Page.text.""" - self.skipTest('See T107537') - self._test_page_text() + self._test_page_text(get_text=False) # See T107537
class TestFlowLoading(TestMediaWikiFlowSandbox):
pywikibot-commits@lists.wikimedia.org