jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1092211?usp=email )
Change subject: [tests] Add tests for BasePage.categories(with_sort_key=True) ...................................................................... [tests] Add tests for BasePage.categories(with_sort_key=True) also update documentation and remove timestamp|hidden clprop because they are not used and their property can be found by other methods. Bug: T73561 Change-Id: If975307630924763ab062365b5a918b00e45be4b --- M pywikibot/page/_basepage.py M pywikibot/site/_generators.py M tests/page_tests.py 3 files changed, 31 insertions(+), 1 deletion(-) Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified diff --git a/pywikibot/page/_basepage.py b/pywikibot/page/_basepage.py index 335f0e3..28ad6db 100644 --- a/pywikibot/page/_basepage.py +++ b/pywikibot/page/_basepage.py @@ -1743,6 +1743,8 @@ *with_sort_key* parameter is supported. .. seealso:: :meth:`Site.pagecategories() <pywikibot.site._generators.GeneratorsMixin.pagecategories>` + .. note:: This method also yields categories which are + transcluded. :param with_sort_key: if True, include the sort key in each Category. diff --git a/pywikibot/site/_generators.py b/pywikibot/site/_generators.py index 0de2182..d77d675 100644 --- a/pywikibot/site/_generators.py +++ b/pywikibot/site/_generators.py @@ -468,6 +468,9 @@ - :meth:`page.BasePage.categories` - :api:`Categories` + .. note:: This method also yields categories which are + transcluded. + :param with_sort_key: if True, include the sort key in each Category :param content: if True, load the current content of each @@ -487,7 +490,7 @@ api.PropertyGenerator, type_arg='categories', total=total, - clprop='sortkey|timestamp|hidden', + clprop='sortkey', **clargs))) cats = ( pywikibot.Category(self, diff --git a/tests/page_tests.py b/tests/page_tests.py index 6b9c294..30bb9b1 100755 --- a/tests/page_tests.py +++ b/tests/page_tests.py @@ -619,6 +619,31 @@ mainpage.page_image() +class TestPageCategories(TestCase): + + """Categories tests class.""" + + family = 'wikipedia' + code = 'en' + + def testCategories(self): + """Test BasePage.categories() with sort keys.""" + mainhelp = pywikibot.Page(self.site, 'Help:Contents') + cat_help = pywikibot.Category(self.site, 'Category:Help') + + for with_sort_key in (False, True): + with self.subTest(with_sort_key=with_sort_key): + cats = list(mainhelp.categories(with_sort_key=with_sort_key)) + self.assertLength(cats, 4) + self.assertIn(cat_help, cats) + for p in cats: + self.assertIsInstance(p, pywikibot.Category) + if with_sort_key: + self.assertEqual(p.sortKey, 'Contents') + else: + self.assertIsNone(p.sortKey) + + class TestPageCoordinates(TestCase): """Test Page Object using German Wikipedia.""" -- To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1092211?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: pywikibot/core Gerrit-Branch: master Gerrit-Change-Id: If975307630924763ab062365b5a918b00e45be4b Gerrit-Change-Number: 1092211 Gerrit-PatchSet: 2 Gerrit-Owner: Xqt <i...@gno.de> Gerrit-Reviewer: Xqt <i...@gno.de> Gerrit-Reviewer: jenkins-bot
_______________________________________________ Pywikibot-commits mailing list -- pywikibot-commits@lists.wikimedia.org To unsubscribe send an email to pywikibot-commits-le...@lists.wikimedia.org