jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/423263 )
Change subject: Fix/suppress user_tests warnings ......................................................................
Fix/suppress user_tests warnings
pywikibot.site.APISite.users: Use parameters argument to pass parameters to ListGenerator. This will avoid the _warn_kwargs in api.Request.
Change-Id: I692f3e2d2e41ee575a1c0f5b6fbc28832a555799 --- M pywikibot/site.py M tests/user_tests.py 2 files changed, 14 insertions(+), 5 deletions(-)
Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/site.py b/pywikibot/site.py index d51e4e7..e952892 100644 --- a/pywikibot/site.py +++ b/pywikibot/site.py @@ -4931,7 +4931,8 @@ if MediaWikiVersion(self.version()) >= MediaWikiVersion('1.17'): usprop.append('rights') usgen = api.ListGenerator( - 'users', ususers=usernames, site=self, usprop=usprop) + 'users', site=self, parameters={ + 'ususers': usernames, 'usprop': usprop}) return usgen
@deprecated('Site.randompages(total=1)') diff --git a/tests/user_tests.py b/tests/user_tests.py index f2a8b06..6691402 100644 --- a/tests/user_tests.py +++ b/tests/user_tests.py @@ -13,6 +13,7 @@ from pywikibot.exceptions import AutoblockUser from pywikibot.tools import StringTypes, suppress_warnings
+from tests import patch from tests.aspects import DefaultSiteTestCase, TestCase, unittest
@@ -131,9 +132,13 @@
def test_autoblocked_user(self): """Test autoblocked user.""" - user = User(self.site, '#1242976') + with patch.object(pywikibot, 'output') as p: + user = User(self.site, '#1242976') + p.assert_called_once_with( + 'This is an autoblock ID, you can only use to unblock it.') self.assertEqual('#1242976', user.username) - self.assertEqual(user.name(), user.username) + with suppress_warnings('pywikibot.page.User.name is deprecated'): + self.assertEqual(user.name(), user.username) self.assertEqual(user.title(withNamespace=False), user.username[1:]) self.assertFalse(user.isRegistered()) self.assertFalse(user.isAnonymous()) @@ -148,9 +153,12 @@
def test_autoblocked_user_with_namespace(self): """Test autoblocked user.""" - user = User(self.site, 'User:#1242976') + # Suppress output: This is an autoblock ID, you can only use to unblock + with patch.object(pywikibot, 'output'): + user = User(self.site, 'User:#1242976') self.assertEqual('#1242976', user.username) - self.assertEqual(user.name(), user.username) + with suppress_warnings('pywikibot.page.User.name is deprecated'): + self.assertEqual(user.name(), user.username) self.assertEqual(user.title(withNamespace=False), user.username[1:]) self.assertFalse(user.isRegistered()) self.assertFalse(user.isAnonymous())
pywikibot-commits@lists.wikimedia.org