jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/337548 )
Change subject: textlib_tests: Don't expect textlib.getCategoryLinks to raise InvalidTitle ......................................................................
textlib_tests: Don't expect textlib.getCategoryLinks to raise InvalidTitle
After fb7f54b6b85f, getCategoryLinks does not raise InvalidTitle anymore, instead a warning is raised. Fix the test according to that change.
Bug: T158032 Change-Id: I4777b2ae555837555629b6ac2725d3ba002f36a0 --- M tests/textlib_tests.py 1 file changed, 8 insertions(+), 2 deletions(-)
Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py index 2cabf39..f98bb42 100644 --- a/tests/textlib_tests.py +++ b/tests/textlib_tests.py @@ -13,6 +13,10 @@ import functools import os import re +try: + from unittest import mock +except ImportError: + import mock
import pywikibot import pywikibot.textlib as textlib @@ -298,8 +302,10 @@ self.assertEqual(textlib.getCategoryLinks( '[[Category:Foo{{!}}and{{!}}bar]]', self.site, expand_text=True), [pywikibot.page.Category(self.site, 'Foo', sortKey='and|bar')]) - self.assertRaises(pywikibot.InvalidTitle, textlib.getCategoryLinks, - '[[Category:nasty{{{!}}]]', self.site) + with mock.patch.object(pywikibot, 'warning', autospec=True) as warn: + textlib.getCategoryLinks('[[Category:nasty{{{!}}]]', self.site) + warn.assert_called_once_with( + 'Invalid category title extracted: nasty{{{!}}')
class TestTemplateParams(TestCase):
pywikibot-commits@lists.wikimedia.org