jenkins-bot submitted this change.

View Change

Approvals: Xqt: Looks good to me, approved jenkins-bot: Verified
[tests] Rename tests 'user' attribute to 'login'

Dualism of user and sysop was given up. Therefore rename
TestCase's 'user' attribute to 'login' which reflects more
the fact that the test user has to be logged in. 'sysop'
attribute is just an alias currently and will be replaced
later.

Bug: T71283
Change-Id: I0d35b0ea21dfa6be1319234c183674e2d8ae9e22
---
M tests/README.rst
M tests/archive/isbn_tests.py
M tests/aspects.py
M tests/checkimages_tests.py
M tests/deletionbot_tests.py
M tests/edit_failure_tests.py
M tests/edit_tests.py
M tests/flow_edit_tests.py
M tests/page_tests.py
M tests/pagegenerators_tests.py
M tests/script_tests.py
M tests/site_tests.py
M tests/token_tests.py
M tests/user_tests.py
M tests/wikibase_edit_tests.py
15 files changed, 49 insertions(+), 52 deletions(-)

diff --git a/tests/README.rst b/tests/README.rst
index 7d47c91..3e2a280 100644
--- a/tests/README.rst
+++ b/tests/README.rst
@@ -329,6 +329,6 @@
- ``net = False`` : test class does not use a site
- ``dry = True`` : test class can use a fake site object
- ``cached = True``: test class may aggressively cache API responses
-- ``user = True`` : test class needs to login to site
+- ``login = True`` : test class needs to login to site
- ``sysop = True`` : test class needs to login to site as a sysop
- ``write = True`` : test class needs to write to a site
diff --git a/tests/archive/isbn_tests.py b/tests/archive/isbn_tests.py
index fde5053..f978851 100644
--- a/tests/archive/isbn_tests.py
+++ b/tests/archive/isbn_tests.py
@@ -150,7 +150,7 @@
family = 'wikipedia'
code = 'test'

- user = True
+ login = True
write = True

def setUp(self):
diff --git a/tests/aspects.py b/tests/aspects.py
index b170903..fc9fb29 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -516,21 +516,18 @@
.format(cls.__name__, site.code, site.family.name))


-class RequireUserMixin(TestCaseBase):
+class RequireLoginMixin(TestCaseBase):

"""Run tests against a specific site, with a login."""

- user = True
+ login = True

@classmethod
- def require_site_user(cls, family, code, sysop=False):
+ def require_site_user(cls, family, code):
"""Check the user config has a valid login to the site."""
if not cls.has_site_user(family, code):
- raise unittest.SkipTest(
- '{}: No {}username for {}:{}'
- .format(cls.__name__,
- 'sysop ' if sysop else '',
- family, code))
+ raise unittest.SkipTest('{}: No username for {}:{}'
+ .format(cls.__name__, family, code))

@classmethod
def setUpClass(cls):
@@ -542,11 +539,11 @@
"""
super().setUpClass()

- sysop = hasattr(cls, 'sysop') and cls.sysop
+ # currently 'sysop' attribute is an alias for 'login'
+ # sysop = hasattr(cls, 'sysop') and cls.sysop

for site_dict in cls.sites.values():
- cls.require_site_user(
- site_dict['family'], site_dict['code'], sysop)
+ cls.require_site_user(site_dict['family'], site_dict['code'])

if hasattr(cls, 'oauth') and cls.oauth:
continue
@@ -593,7 +590,7 @@

if not site.logged_in():
site.login()
- assert(site.user())
+ assert site.user()

def get_userpage(self, site=None):
"""Create a User object for the user's userpage."""
@@ -759,8 +756,8 @@
dct.setdefault('user', True)
bases = cls.add_base(bases, SiteWriteMixin)

- if dct.get('user') or dct.get('sysop'):
- bases = cls.add_base(bases, RequireUserMixin)
+ if dct.get('login') or dct.get('sysop'):
+ bases = cls.add_base(bases, RequireLoginMixin)

for test in tests:
test_func = dct[test]
diff --git a/tests/checkimages_tests.py b/tests/checkimages_tests.py
index f5876fd..b2def76 100644
--- a/tests/checkimages_tests.py
+++ b/tests/checkimages_tests.py
@@ -18,7 +18,7 @@

family = 'commons'
code = 'commons'
- user = True
+ login = True

def test_load(self):
"""Test loading settings."""
diff --git a/tests/deletionbot_tests.py b/tests/deletionbot_tests.py
index 8aeffec..9ba451f 100644
--- a/tests/deletionbot_tests.py
+++ b/tests/deletionbot_tests.py
@@ -57,7 +57,7 @@
family = 'wikipedia'
code = 'test'

- user = True
+ login = True
write = True

def test_delete_mark(self):
@@ -83,7 +83,7 @@
code = 'test'

cached = True
- user = True
+ login = True

delete_args = []
undelete_args = []
diff --git a/tests/edit_failure_tests.py b/tests/edit_failure_tests.py
index 4d45474..bbc736d 100644
--- a/tests/edit_failure_tests.py
+++ b/tests/edit_failure_tests.py
@@ -36,7 +36,7 @@

"""Test cases for edits which should fail to save."""

- user = True
+ login = True
write = -1

family = 'wikipedia'
@@ -112,7 +112,7 @@

"""Test cases for actions which should fail to save."""

- user = True
+ login = True
write = -1

family = 'wikipedia'
@@ -143,7 +143,7 @@
family = 'wikidata'
code = 'test'

- user = True
+ login = True
write = -1

def test_itempage_save(self):
diff --git a/tests/edit_tests.py b/tests/edit_tests.py
index ee04c1a..03da79d 100644
--- a/tests/edit_tests.py
+++ b/tests/edit_tests.py
@@ -27,7 +27,7 @@
family = 'wikipedia'
code = 'test'

- user = True
+ login = True
write = True

def test_createonly(self):
diff --git a/tests/flow_edit_tests.py b/tests/flow_edit_tests.py
index d6120d3..8c0ac0e 100644
--- a/tests/flow_edit_tests.py
+++ b/tests/flow_edit_tests.py
@@ -24,7 +24,7 @@
family = 'wikipedia'
code = 'test'

- user = True
+ login = True
write = True

def test_create_topic(self):
@@ -47,7 +47,7 @@
family = 'wikipedia'
code = 'test'

- user = True
+ login = True
write = True

@classmethod
@@ -164,7 +164,7 @@
family = 'wikipedia'
code = 'test'

- user = True
+ login = True
write = True

def test_lock_unlock_topic(self):
@@ -189,7 +189,7 @@
family = 'wikipedia'
code = 'test'

- user = True
+ login = True
write = -1

def test_reply_to_locked_topic(self):
@@ -215,7 +215,7 @@
family = 'wikipedia'
code = 'test'

- user = True
+ login = True
write = True

def setUp(self):
diff --git a/tests/page_tests.py b/tests/page_tests.py
index ccdbab3..f6ce4f8 100644
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -736,7 +736,7 @@
code = 'test'

cached = True
- user = True
+ login = True

def setUp(self):
"""Setup test."""
@@ -1009,7 +1009,7 @@

"""Test page user actions."""

- user = True
+ login = True

def test_purge(self):
"""Test purging the mainpage."""
@@ -1237,7 +1237,7 @@
class TestShortLink(TestCase):
"""Test that short link management is correct."""

- user = True
+ login = True

family = 'wikipedia'
code = 'test'
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py
index a35cce4..5bf1bec 100755
--- a/tests/pagegenerators_tests.py
+++ b/tests/pagegenerators_tests.py
@@ -1498,7 +1498,7 @@
if len(newuser_logevents) == 0:
raise unittest.SkipTest('No newuser logs found to test with.')

- user = True
+ login = True

def test_logevents_parse(self):
"""Test wrong logevents option."""
diff --git a/tests/script_tests.py b/tests/script_tests.py
index 7968462..b168df3 100644
--- a/tests/script_tests.py
+++ b/tests/script_tests.py
@@ -364,7 +364,7 @@
run in pwb can automatically login using the saved cookies.
"""

- user = True
+ login = True

_expected_failures = {
'catall', # stdout user interaction
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 3f3a863..2e6c595 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -1123,7 +1123,7 @@

"""Test site method using a user."""

- user = True
+ login = True

def test_methods(self):
"""Test user related methods."""
@@ -1379,7 +1379,7 @@

"""Test recentchanges method requiring a user."""

- user = True
+ login = True

def test_patrolled(self):
"""Test the site.recentchanges() with patrolled boolean flags."""
@@ -1398,7 +1398,7 @@

"""Test user watched pages."""

- user = True
+ login = True

def test_watched_pages(self):
"""Test the site.watched_pages() method."""
@@ -1489,7 +1489,7 @@

"""Test site method site.usercontribs() with bot user."""

- user = True
+ login = True

def test_basic(self):
"""Test the site.usercontribs() method."""
@@ -1615,7 +1615,7 @@

"""Test site method site.alldeletedrevisions() with bot user."""

- user = True
+ login = True

@classmethod
def setUpClass(cls):
@@ -1802,7 +1802,7 @@

"""Test site method watchlist_revs()."""

- user = True
+ login = True

def test_watchlist_revs(self):
"""Test the site.watchlist_revs() method."""
@@ -2204,7 +2204,7 @@

"""Test that the user account can be found in users list."""

- user = True
+ login = True
cached = True

def test_username_in_users(self):
@@ -2705,7 +2705,7 @@
}
}

- user = True
+ login = True

def test_is_uploaddisabled(self, key):
"""Test is_uploaddisabled()."""
@@ -3469,7 +3469,7 @@

"""Test for login and logout methods."""

- user = True
+ login = True

def test_login_logout(self):
"""Validate login and logout methods by toggling the state."""
@@ -3504,7 +3504,7 @@
class TestClearCookies(TestCase):
"""Test cookies are cleared after logout."""

- user = True
+ login = True

family = 'wikisource'
code = 'zh'
diff --git a/tests/token_tests.py b/tests/token_tests.py
index 8e2de1f..b3b6691 100644
--- a/tests/token_tests.py
+++ b/tests/token_tests.py
@@ -31,7 +31,7 @@

"""

- user = True
+ login = True

def setUp(self):
"""Store version."""
@@ -125,9 +125,9 @@

family = 'wikipedia'
code = 'test'
-
- user = True
token_type = 'patrol'
+
+ login = True
write = True

def test_patrol(self):
@@ -176,7 +176,7 @@
"""Test cases for Site patrol token deprecated methods."""

cached = True
- user = True
+ login = True

def test_get_patrol_token(self):
"""Test site.getPatrolToken."""
diff --git a/tests/user_tests.py b/tests/user_tests.py
index 4093983..b6344e6 100644
--- a/tests/user_tests.py
+++ b/tests/user_tests.py
@@ -171,7 +171,7 @@

"""Test User methods with bot user."""

- user = True
+ login = True

def test_contribution(self):
"""Test the User.usercontribs() method."""
diff --git a/tests/wikibase_edit_tests.py b/tests/wikibase_edit_tests.py
index fa03f79..90e0d44 100644
--- a/tests/wikibase_edit_tests.py
+++ b/tests/wikibase_edit_tests.py
@@ -26,7 +26,7 @@
family = 'wikidata'
code = 'test'

- user = True
+ login = True
write = True

def test_label_set(self):
@@ -204,7 +204,7 @@
family = 'wikidata'
code = 'test'

- user = True
+ login = True
write = True

def _clean_item(self, repo, prop: str):
@@ -405,7 +405,7 @@
family = 'wikidata'
code = 'test'

- user = True
+ login = True
write = True

def setUp(self):
@@ -482,7 +482,7 @@
family = 'wikidata'
code = 'test'

- user = True
+ login = True
write = True

def setUp(self):

To view, visit change 672448. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I0d35b0ea21dfa6be1319234c183674e2d8ae9e22
Gerrit-Change-Number: 672448
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info@gno.de>
Gerrit-Reviewer: Huji <huji.huji@gmail.com>
Gerrit-Reviewer: Xqt <info@gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged