jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/333216 )
Change subject: pagegenerators_tests.py: Test that getCategory returns the correct site ......................................................................
pagegenerators_tests.py: Test that getCategory returns the correct site
0c33e28954b341ac32065198e5103d2ffa9b3eda fixed a bug that was causing getCategory return a category from the wrong site (the default site instead of the user-specified site). This patch adds a test for it.
Bug: T155687 Change-Id: I062a8af1c912ad6830cab81305d89cd34b873250 --- M tests/pagegenerators_tests.py 1 file changed, 16 insertions(+), 3 deletions(-)
Approvals: jenkins-bot: Verified Sn1per: Looks good to me, approved
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py index 77eba56..133caf8 100755 --- a/tests/pagegenerators_tests.py +++ b/tests/pagegenerators_tests.py @@ -2,12 +2,10 @@ # -*- coding: utf-8 -*- """Test pagegenerators module.""" # -# (C) Pywikibot team, 2009-2016 +# (C) Pywikibot team, 2009-2017 # # Distributed under the terms of the MIT license. from __future__ import absolute_import, unicode_literals - -__version__ = '$Id$'
import calendar import datetime @@ -38,6 +36,9 @@ RecentChangesTestCase, ) from tests.thread_tests import GeneratorIntersectTestCase + + +__version__ = '$Id$'
en_wp_page_titles = ( # just a bunch of randomly selected titles for English Wikipedia tests @@ -1110,6 +1111,18 @@ page2 = next(gen) self.assertEqual(page2.title(), 'Q286874')
+ def test_get_category_site(self): + """Test the getCategory method.""" + # With default site + gf = pagegenerators.GeneratorFactory() + cat = gf.getCategory('foo')[0] + self.assertEqual(cat.site, pywikibot.Site()) + # With a user-specified site + fa_wikisource = pywikibot.Site('fa', 'wikisource') + gf = pagegenerators.GeneratorFactory(fa_wikisource) + cat = gf.getCategory('foo')[0] + self.assertEqual(cat.site, fa_wikisource) +
class TestLogeventsFactoryGenerator(DefaultSiteTestCase, DeprecationTestCase):
pywikibot-commits@lists.wikimedia.org