Xqt has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/636681 )
Change subject: [tests] remove deprecated sysop parameter of several test methods ......................................................................
[tests] remove deprecated sysop parameter of several test methods
Change-Id: I08a220bbd670f7571af0811c12d93bae95d4f10d --- M tests/aspects.py M tests/deletionbot_tests.py M tests/redirect_bot_tests.py M tests/site_tests.py 4 files changed, 10 insertions(+), 22 deletions(-)
Approvals: jenkins-bot: Verified Xqt: Looks good to me, approved
diff --git a/tests/aspects.py b/tests/aspects.py index 2ab9f6e..5c25e59 100644 --- a/tests/aspects.py +++ b/tests/aspects.py @@ -667,12 +667,8 @@ if self._userpage.site == site: return self._userpage
- sysop = hasattr(self, 'sysop') and self.sysop - - userpage = pywikibot.User(site, site.username(sysop)) - + userpage = pywikibot.User(site, site.username()) self._userpage = userpage - return userpage
diff --git a/tests/deletionbot_tests.py b/tests/deletionbot_tests.py index 09fd736..b035087 100644 --- a/tests/deletionbot_tests.py +++ b/tests/deletionbot_tests.py @@ -62,9 +62,6 @@ def test_delete_mark(self): """Test marking User:Unicodesnowman/DeleteMark for deletion.""" site = self.get_site() - if site.username(sysop=True): - self.skipTest("can't test mark with sysop account") - p1 = pywikibot.Page(site, 'User:Unicodesnowman/DeleteMark') if not p1.exists(): p1.text = 'foo' diff --git a/tests/redirect_bot_tests.py b/tests/redirect_bot_tests.py index 6135408..5986f34 100644 --- a/tests/redirect_bot_tests.py +++ b/tests/redirect_bot_tests.py @@ -1,14 +1,14 @@ # -*- coding: utf-8 -*- """Tests for the redirect.py script.""" # -# (C) Pywikibot team, 2017-2019 +# (C) Pywikibot team, 2017-2020 # # Distributed under the terms of the MIT license. # -from __future__ import absolute_import, division, unicode_literals +from contextlib import suppress
import pywikibot -from pywikibot import site, Page, i18n +from pywikibot import Page, i18n
from scripts.redirect import RedirectRobot
@@ -16,8 +16,6 @@ from tests.aspects import DefaultSiteTestCase
-# To make `self.site.logged_in(sysop=True)` always return False -@patch.object(site.APISite, 'logged_in', new=Mock(return_value=False)) @patch.object(Page, 'exists', new=Mock(return_value=True)) class TestGetSDTemplateNoSysop(DefaultSiteTestCase):
@@ -55,7 +53,5 @@
if __name__ == '__main__': # pragma: no cover - try: + with suppress(SystemExit): unittest.main() - except SystemExit: - pass diff --git a/tests/site_tests.py b/tests/site_tests.py index 069fafe..245ca88 100644 --- a/tests/site_tests.py +++ b/tests/site_tests.py @@ -347,7 +347,6 @@ """Test returned types of user attributes.""" mysite = self.get_site() self.assertIsInstance(mysite.logged_in(), bool) - self.assertIsInstance(mysite.logged_in(True), bool) self.assertIsInstance(mysite.userinfo, dict)
def test_messages(self): @@ -1841,11 +1840,11 @@ def test_methods(self): """Test sysop related methods.""" mysite = self.get_site() - self.assertIsInstance(mysite.is_blocked(True), bool) - self.assertIsInstance(mysite.has_right('edit', True), bool) - self.assertFalse(mysite.has_right('nonexistent_right', True)) - self.assertIsInstance(mysite.has_group('bots', True), bool) - self.assertFalse(mysite.has_group('nonexistent_group', True)) + self.assertIsInstance(mysite.is_blocked(), bool) + self.assertIsInstance(mysite.has_right('edit'), bool) + self.assertFalse(mysite.has_right('nonexistent_right')) + self.assertIsInstance(mysite.has_group('bots'), bool) + self.assertFalse(mysite.has_group('nonexistent_group'))
def test_deletedrevs(self): """Test the site.deletedrevs() method."""
pywikibot-commits@lists.wikimedia.org