jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/759535 )
Change subject: [DOCS] Pywikibot: Add missing docsting params and update comments
......................................................................
[DOCS] Pywikibot: Add missing docsting params and update comments
Desciption for following params are added:
-In _collections.py param key of normalizeKey method of class BaseDataDict
-In chars.py param string of string_to_ascii_html method CHECK CLASS
-In djvu.py param n of page_info method of class DjVuFile
-In djvu.py param data of _remove_control_chars method of class DjVuFile
-In djvu.py param n of get_page method of class DjVuFile
-In djvu.py param n of whiten_page method of class DjVuFile
-In djvu.py param n of delete_page method of class DjVuFile
Comment updated
-In _deprecate.py param obj of add_decorated_full_name method, message typo removed
Bug: T184115
Change-Id: Ib965401e1459e6463a8cd692eefd83ef248d63e5
---
M pywikibot/page/_collections.py
M pywikibot/tools/_deprecate.py
M pywikibot/tools/chars.py
M pywikibot/tools/djvu.py
4 files changed, 26 insertions(+), 5 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page/_collections.py b/pywikibot/page/_collections.py
index 7cd7c4a..6668a45 100644
--- a/pywikibot/page/_collections.py
+++ b/pywikibot/page/_collections.py
@@ -67,7 +67,11 @@
@staticmethod
def normalizeKey(key) -> str:
- """Helper function to return language codes of a site object."""
+ """Helper function to return language codes of a site object.
+
+ :param key: input key to be normalized
+ :type key: pywikibot.site.BaseSite or str
+ """
if isinstance(key, BaseSite):
key = key.lang
return key
diff --git a/pywikibot/tools/_deprecate.py b/pywikibot/tools/_deprecate.py
index 1c874af..de68157 100644
--- a/pywikibot/tools/_deprecate.py
+++ b/pywikibot/tools/_deprecate.py
@@ -50,7 +50,7 @@
This must be done on all decorators that are chained together, otherwise
the second decorator will have the wrong full name.
- :param obj: A object being decorated
+ :param obj: An object being decorated
:type obj: object
:param stacklevel: level to use
:type stacklevel: int
diff --git a/pywikibot/tools/chars.py b/pywikibot/tools/chars.py
index c162555..a2fd898 100644
--- a/pywikibot/tools/chars.py
+++ b/pywikibot/tools/chars.py
@@ -44,7 +44,10 @@
def string_to_ascii_html(string: str) -> str:
- """Convert unicode chars of str to HTML entities if chars are not ASCII."""
+ """Convert unicode chars of str to HTML entities if chars are not ASCII.
+
+ :param string: String to update
+ """
html = []
for c in string:
cord = ord(c)
diff --git a/pywikibot/tools/djvu.py b/pywikibot/tools/djvu.py
index e4f7c65..83c2873 100644
--- a/pywikibot/tools/djvu.py
+++ b/pywikibot/tools/djvu.py
@@ -135,6 +135,8 @@
"""
Return a tuple (id, (size, dpi)) for page n of djvu file.
+ :param n: page n of djvu file
+ :type n: int
:param force: if True, refresh the cached data
:type force: bool
"""
@@ -206,6 +208,8 @@
"""Remove djvu format control characters.
See http://djvu.sourceforge.net/doc/man/djvused.html for control chars.
+
+ :param data: the data checked for djvu format control characters
"""
txt = data.decode('utf-8')
# vertical tab (\013=\x0b): remove
@@ -224,6 +228,8 @@
"""
Get page n for djvu file.
+ :param n: page n of djvu file
+ :type n: int
:param force: if True, refresh the cached data
:type force: bool
"""
@@ -238,7 +244,11 @@
@check_page_number
def whiten_page(self, n):
- """Replace page 'n' of djvu file with a blank page."""
+ """Replace page 'n' of djvu file with a blank page.
+
+ :param n: page n of djvu file
+ :type n: int
+ """
# tmp files for creation/insertion of a white page.
white_ppm = os.path.join(self.dirname, 'white_page.ppm')
white_djvu = os.path.join(self.dirname, 'white_page.djvu')
@@ -285,7 +295,11 @@
@check_page_number
def delete_page(self, n):
- """Delete page 'n' of djvu file ."""
+ """Delete page 'n' of djvu file.
+
+ :param n: page n of djvu file
+ :type n: int
+ """
n_tot = self.number_of_images()
# Check n is in valid range and set ref_page number for final checks.
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/759535
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: Ib965401e1459e6463a8cd692eefd83ef248d63e5
Gerrit-Change-Number: 759535
Gerrit-PatchSet: 1
Gerrit-Owner: Lorcan <lorcanjames1(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/761893 )
Change subject: [bugfix] Never fail RequireLoginMixin during tearDown().
......................................................................
[bugfix] Never fail RequireLoginMixin during tearDown().
- Tests with RequireLoginMixin should not fail during tearDown
and testmethods may be skipped during setUp like it is implemented
in setUpClass()
- exclude site_login_logout_tests from tests; it is tested by a
seprate Login CI action
Bug: T301545
Change-Id: I2660c99a77e95f64b0b700960f580bc8cb810eb8
---
M tests/__init__.py
M tests/aspects.py
2 files changed, 19 insertions(+), 8 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/__init__.py b/tests/__init__.py
index b54e2c2..b6e5456 100644
--- a/tests/__init__.py
+++ b/tests/__init__.py
@@ -172,6 +172,7 @@
disabled_test_modules = {
'tests', # tests of the tests package
'l10n', # pywikibot-i18n repository runs it
+ 'site_login_logout', # separate Login CI action
}
disabled_tests = {} # type: Dict[str, List[str]]
diff --git a/tests/aspects.py b/tests/aspects.py
index cab9da7..ac67b43 100644
--- a/tests/aspects.py
+++ b/tests/aspects.py
@@ -5,7 +5,7 @@
such as API result caching and excessive test durations.
"""
#
-# (C) Pywikibot team, 2014-2021
+# (C) Pywikibot team, 2014-2022
#
# Distributed under the terms of the MIT license.
#
@@ -588,18 +588,25 @@
Login to the site if it is not logged in.
"""
super().setUp()
- self._reset_login()
+ self._reset_login(True)
def tearDown(self):
"""Log back into the site."""
super().tearDown()
self._reset_login()
- def _reset_login(self):
- """Login to all sites."""
- # There may be many sites, and setUp doesn't know
- # which site is to be tested; ensure they are all
- # logged in.
+ def _reset_login(self, skip_if_login_fails: bool = False):
+ """Login to all sites.
+
+ There may be many sites, and setUp doesn't know which site is to
+ be tested; ensure they are all logged in.
+
+ .. versionadded:: 7.0
+ The `skip_if_login_fails` parameter.
+
+ :param skip_if_login_fails: called with setUp(); if True, skip
+ the current current test.
+ """
for site in self.sites.values():
site = site['site']
@@ -608,7 +615,10 @@
if not site.logged_in():
site.login()
- assert site.user()
+
+ if skip_if_login_fails and not site.user(): # during setUp() only
+ self.skipTest('{}: Not able to re-login to {}'
+ .format(type(self).__name__, site))
def get_userpage(self, site=None):
"""Create a User object for the user's userpage."""
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/761893
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I2660c99a77e95f64b0b700960f580bc8cb810eb8
Gerrit-Change-Number: 761893
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged