jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/492540 )
Change subject: [i18n] Change message for category_redirect-log-false-positive
......................................................................
[i18n] Change message for category_redirect-log-false-positive
The doc says for this message:
"Log message indicating category page was not redirect"
Make this message more informative instead of just "False positive"
because nobody understand what this means inside the log file.
Note: Only the en message has to be changed. All other translations
are marked by fuzzy bot at twn to be translated due to this change.
Change-Id: If5f115b849569c7d88c89354b08ab2d4b726fa97
---
M category_redirect/en.json
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/category_redirect/en.json b/category_redirect/en.json
index 4f16138..52529c7 100644
--- a/category_redirect/en.json
+++ b/category_redirect/en.json
@@ -14,7 +14,7 @@
"category_redirect-log-add-failed": "* Failed to add [[%(ns)s%(template)s]] to %(oldcat)s",
"category_redirect-log-double": "* Fixed double-redirect: %(oldcat)s -> %(newcat)s -> %(targetcat)s",
"category_redirect-log-failed": "** Failed: %(error)s",
- "category_redirect-log-false-positive": "* False positive: %(oldcat)s",
+ "category_redirect-log-false-positive": "* Unexpected non-redirect: %(oldcat)s",
"category_redirect-log-ignoring": "* Ignoring %(oldcat)s",
"category_redirect-log-loop": "* Redirect loop from %(oldcat)s",
"category_redirect-log-moved": "* %(oldcat)s: %(found)d found, %(moved)d moved",
--
To view, visit https://gerrit.wikimedia.org/r/492540
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/i18n
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: If5f115b849569c7d88c89354b08ab2d4b726fa97
Gerrit-Change-Number: 492540
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Siebrand <siebrand(a)kitano.nl>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/490000 )
Change subject: [tests] Use skipTest method instead of raising SkipTest exception
......................................................................
[tests] Use skipTest method instead of raising SkipTest exception
TestCase skipTest was introduced in python 2.7 and 3.1 and may be called
during test methods and setUp method. skipTest method or skipping decorators
are the usual way to skip a test instead raising unittest.SkipTest directly
(see https://docs.python.org/3/library/unittest.html#unittest-skipping)
Change-Id: Id9abf50e697974de48679e69587dcf8989b22ba8
---
M tests/api_tests.py
M tests/deletionbot_tests.py
M tests/edit_failure_tests.py
M tests/edit_tests.py
M tests/family_tests.py
M tests/logentry_tests.py
M tests/oauth_tests.py
M tests/page_tests.py
M tests/pagegenerators_tests.py
M tests/site_tests.py
M tests/tools_tests.py
M tests/wikibase_edit_tests.py
M tests/wikibase_tests.py
M tests/wikistats_tests.py
14 files changed, 92 insertions(+), 100 deletions(-)
Approvals:
Dalba: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/api_tests.py b/tests/api_tests.py
index e1f9d2c..137b8aa 100644
--- a/tests/api_tests.py
+++ b/tests/api_tests.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""API test module."""
#
-# (C) Pywikibot team, 2007-2018
+# (C) Pywikibot team, 2007-2019
#
# Distributed under the terms of the MIT license.
#
@@ -476,7 +476,7 @@
"""Test the new modules-only mode explicitly."""
site = self.get_site()
if site.mw_version < '1.25wmf4':
- raise unittest.SkipTest(
+ self.skipTest(
"version {} doesn't support the new paraminfo api"
.format(site.mw_version))
pi = api.ParamInfo(site, modules_only_mode=True)
@@ -1125,7 +1125,7 @@
mysite = self.get_site()
if ('dbrepllag' not in mysite.siteinfo
or mysite.siteinfo['dbrepllag'][0]['lag'] == -1):
- raise unittest.SkipTest(
+ self.skipTest(
'{0} is not running on a replicated database cluster.'
.format(mysite)
)
diff --git a/tests/deletionbot_tests.py b/tests/deletionbot_tests.py
index b7d991f..6607df7 100644
--- a/tests/deletionbot_tests.py
+++ b/tests/deletionbot_tests.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Tests for scripts/delete.py."""
#
-# (C) Pywikibot team, 2014-2018
+# (C) Pywikibot team, 2014-2019
#
# Distributed under the terms of the MIT license.
#
@@ -62,7 +62,7 @@
"""Test marking User:Unicodesnowman/DeleteMark for deletion."""
site = self.get_site()
if site.username(sysop=True):
- raise unittest.SkipTest("can't test mark with sysop account")
+ self.skipTest("can't test mark with sysop account")
p1 = pywikibot.Page(site, 'User:Unicodesnowman/DeleteMark')
if not p1.exists():
diff --git a/tests/edit_failure_tests.py b/tests/edit_failure_tests.py
index 9182992..7470713 100644
--- a/tests/edit_failure_tests.py
+++ b/tests/edit_failure_tests.py
@@ -8,7 +8,7 @@
These tests use special code 'write = -1' for edit failures.
"""
#
-# (C) Pywikibot team, 2014-2018
+# (C) Pywikibot team, 2014-2019
#
# Distributed under the terms of the MIT license.
#
@@ -44,8 +44,8 @@
def test_protected(self):
"""Test that protected titles raise the appropriate exception."""
if self.site.has_group('sysop'):
- raise unittest.SkipTest('Testing failure of edit protected with '
- 'a sysop account')
+ self.skipTest(
+ 'Testing failure of edit protected with a sysop account')
page = pywikibot.Page(self.site, 'Wikipedia:Create a new page')
self.assertRaises(LockedPage, page.save)
@@ -109,10 +109,8 @@
"""Test that site.movepage raises the appropriate exceptions."""
mysite = self.get_site()
mainpage = self.get_mainpage()
- try:
- mysite.tokens['move']
- except KeyError:
- raise unittest.SkipTest(
+ if 'move' not in mysite.tokens:
+ self.skipTest(
"movepage test requires 'move' token not given to user on {}"
.format(self.site))
diff --git a/tests/edit_tests.py b/tests/edit_tests.py
index bf638a5..bbb1d5d 100644
--- a/tests/edit_tests.py
+++ b/tests/edit_tests.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Tests for editing pages."""
#
-# (C) Pywikibot team, 2015-2018
+# (C) Pywikibot team, 2015-2019
#
# Distributed under the terms of the MIT license.
#
@@ -88,8 +88,8 @@
# Make sure the wiki supports action=mergehistory
if site.mw_version < '1.27.0-wmf.13':
- raise unittest.SkipTest('Wiki version must be 1.27.0-wmf.13 or '
- 'newer to support the history merge API.')
+ self.skipTest('Wiki version must be 1.27.0-wmf.13 or newer to '
+ 'support the history merge API.')
if source.exists():
source.delete('Pywikibot merge history unit test')
diff --git a/tests/family_tests.py b/tests/family_tests.py
index 3a7508b..eca3bcb 100644
--- a/tests/family_tests.py
+++ b/tests/family_tests.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Tests for the family module."""
#
-# (C) Pywikibot team, 2014-2018
+# (C) Pywikibot team, 2014-2019
#
# Distributed under the terms of the MIT license.
#
@@ -238,7 +238,7 @@
"""Test each family builds a working regex."""
for family in pywikibot.config.family_files:
if family == 'wowwiki':
- raise unittest.SkipTest(
+ self.skipTest(
'Family.from_url() does not work for wowwiki (T215077)')
self.current_family = family
family = Family.load(family)
diff --git a/tests/logentry_tests.py b/tests/logentry_tests.py
index 348701a..cdfb109 100644
--- a/tests/logentry_tests.py
+++ b/tests/logentry_tests.py
@@ -212,7 +212,7 @@
# main page was moved around
mainpage = self.get_mainpage(self.site)
if self.sites[key]['target'] is None:
- raise unittest.SkipTest('No moved target')
+ self.skipTest('No moved target')
target = mainpage.moved_target()
self.assertIsInstance(target, pywikibot.Page)
self.assertEqual(target.title(),
@@ -291,7 +291,7 @@
"""Test getMovedTarget method."""
# main page was moved around
if self.sites[key]['target'] is None:
- raise unittest.SkipTest('No moved target')
+ self.skipTest('No moved target')
mainpage = self.get_mainpage(self.site)
target = mainpage.getMovedTarget()
self.assertIsInstance(target, pywikibot.Page)
diff --git a/tests/oauth_tests.py b/tests/oauth_tests.py
index f889a0b..e211ae9 100644
--- a/tests/oauth_tests.py
+++ b/tests/oauth_tests.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Test OAuth functionality."""
#
-# (C) Pywikibot team, 2015-2018
+# (C) Pywikibot team, 2015-2019
#
# Distributed under the terms of the MIT license.
#
@@ -38,10 +38,10 @@
super(OAuthSiteTestCase, self).setUp()
self.site = self.get_site()
if not self.site.has_extension('OAuth'):
- raise unittest.SkipTest('OAuth extension not loaded on test site')
+ self.skipTest('OAuth extension not loaded on test site')
tokens = self._get_oauth_tokens()
if tokens is None:
- raise unittest.SkipTest('OAuth tokens not set')
+ self.skipTest('OAuth tokens not set')
self.assertEqual(len(tokens), 4)
self.consumer_token = tokens[:2]
self.access_token = tokens[2:]
diff --git a/tests/page_tests.py b/tests/page_tests.py
index 4b99130..66e5e59 100644
--- a/tests/page_tests.py
+++ b/tests/page_tests.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Tests for the page module."""
#
-# (C) Pywikibot team, 2008-2018
+# (C) Pywikibot team, 2008-2019
#
# Distributed under the terms of the MIT license.
#
@@ -473,8 +473,8 @@
mainpage = self.get_mainpage()
maintalk = mainpage.toggleTalkPage()
if not maintalk.exists():
- raise unittest.SkipTest("No talk page for {}'s main page"
- .format(self.get_site()))
+ self.skipTest("No talk page for {}'s main page"
+ .format(self.get_site()))
self.assertIsInstance(maintalk.get(get_redirect=True), unicode)
self.assertEqual(mainpage.toggleTalkPage(), maintalk)
self.assertEqual(maintalk.toggleTalkPage(), mainpage)
@@ -488,8 +488,7 @@
"""Test the integration with Extension:Disambiguator."""
site = self.get_site()
if not site.has_extension('Disambiguator'):
- raise unittest.SkipTest(
- 'Disambiguator extension not loaded on test site')
+ self.skipTest('Disambiguator extension not loaded on test site')
pg = pywikibot.Page(site, 'Random')
pg._pageprops = {'disambiguation', ''}
self.assertTrue(pg.isDisambig())
@@ -522,7 +521,7 @@
def testLinks(self):
"""Test the different types of links from a page."""
if self.site.family.name in ('wpbeta', 'wsbeta'):
- raise unittest.SkipTest('Test fails on betawiki; T69931; T160308')
+ self.skipTest('Test fails on betawiki; T69931; T160308')
mainpage = self.get_mainpage()
for p in mainpage.linkedPages():
self.assertIsInstance(p, pywikibot.Page)
@@ -559,8 +558,7 @@
for page in site.allpages(filterredir=True, total=1):
break
else:
- raise unittest.SkipTest('No redirect pages on site {0!r}'
- .format(site))
+ self.skipTest('No redirect pages on site {0!r}'.format(site))
# This page is already initialised
self.assertTrue(hasattr(page, '_isredir'))
# call api.update_page without prop=info
@@ -779,7 +777,7 @@
page = pywikibot.Page(site, 'not_existent_page_for_pywikibot_tests')
if page.exists():
- raise unittest.SkipTest(
+ self.skipTest(
'Page {} exists! Change page name in tests/page_tests.py'
.format(page.title()))
diff --git a/tests/pagegenerators_tests.py b/tests/pagegenerators_tests.py
index a32debf..8027b6e 100755
--- a/tests/pagegenerators_tests.py
+++ b/tests/pagegenerators_tests.py
@@ -463,7 +463,7 @@
# Some languages are missing (T85681)
if (site.lang not in date.formats['YearBC']
or site.lang not in date.formats['YearAD']):
- raise unittest.SkipTest(
+ self.skipTest(
'Date formats for this language are missing from date.py')
start = -20
end = 2026
@@ -1136,7 +1136,7 @@
"""Test the pages_with_property_generator method."""
mysite = self.get_site()
if mysite.mw_version < '1.21':
- raise unittest.SkipTest('requires v1.21+')
+ self.skipTest('requires v1.21+')
for item in ('defaultsort', 'disambiguation', 'displaytitle',
'hiddencat', 'invalid_property'):
if item in mysite.get_property_names():
@@ -1192,9 +1192,8 @@
def test_linter_generator_ns_valid_cat(self):
"""Test generator of pages with lint errors."""
if not self.site.has_extension('Linter'):
- raise unittest.SkipTest(
- 'The site {0} does not use Linter extension'
- .format(self.site))
+ self.skipTest('The site {0} does not use Linter extension'
+ .format(self.site))
gf = pagegenerators.GeneratorFactory(site=self.site)
gf.handleArg('-ns:1')
gf.handleArg('-limit:3')
@@ -1211,9 +1210,8 @@
def test_linter_generator_invalid_cat(self):
"""Test generator of pages with lint errors."""
if not self.site.has_extension('Linter'):
- raise unittest.SkipTest(
- 'The site {0} does not use Linter extension'
- .format(self.site))
+ self.skipTest('The site {0} does not use Linter extension'
+ .format(self.site))
gf = pagegenerators.GeneratorFactory(site=self.site)
self.assertRaises(ValueError, gf.handleArg, '-linter:dummy')
@@ -1598,7 +1596,7 @@
def test_unconnected_with_repo(self):
"""Test UnconnectedPageGenerator."""
if not self.site.data_repository():
- raise unittest.SkipTest('Site is not using a Wikibase repository')
+ self.skipTest('Site is not using a Wikibase repository')
with suppress_warnings(
'pywikibot.pagegenerators.UnconnectedPageGenerator is '
'deprecated', DeprecationWarning):
@@ -1618,7 +1616,7 @@
def test_unconnected_without_repo(self):
"""Test that it raises a ValueError on sites without repository."""
if self.site.data_repository():
- raise unittest.SkipTest('Site is using a Wikibase repository')
+ self.skipTest('Site is using a Wikibase repository')
with self.assertRaises(ValueError):
for page in pagegenerators.UnconnectedPageGenerator(self.site,
total=5):
diff --git a/tests/site_tests.py b/tests/site_tests.py
index 86b654f..d55d64e 100644
--- a/tests/site_tests.py
+++ b/tests/site_tests.py
@@ -66,7 +66,7 @@
unicode(error_msg),
"Action '[a-z]+' is not allowed for user .* on .* wiki.")
self.assertNotIn(self.token_type, self.site.tokens)
- raise unittest.SkipTest(error_msg)
+ self.skipTest(error_msg)
self.token = token
self._orig_wallet = self.site.tokens
@@ -113,7 +113,7 @@
def test_siteinfo_normal_call(self):
"""Test calling the Siteinfo without setting dump."""
if self.site.mw_version < '1.16':
- raise unittest.SkipTest('requires v1.16+')
+ self.skipTest('requires v1.16+')
old = self.site.siteinfo('general')
self.assertIn('time', old)
@@ -433,7 +433,7 @@
"""Test Site methods using English specific inputs and outputs."""
mysite = self.get_site()
if mysite.lang != 'en':
- raise unittest.SkipTest(
+ self.skipTest(
'English-specific tests not valid on {}'.format(mysite))
self.assertEqual(mysite.months_names[4], ('May', 'May'))
@@ -677,7 +677,7 @@
"""Test allpages with langlinks enabled."""
mysite = self.get_site()
if mysite.family.name in ('wpbeta', 'wsbeta'):
- raise unittest.SkipTest('Test fails on betawikis; T199085')
+ self.skipTest('Test fails on betawikis; T199085')
for page in mysite.allpages(
filterlanglinks=True, total=3, namespace=4):
self.assertIsInstance(page, pywikibot.Page)
@@ -730,7 +730,7 @@
def test_all_links(self):
"""Test the site.alllinks() method."""
if self.site.family.name == 'wsbeta':
- raise unittest.SkipTest('Test fails on betawiki; T69931')
+ self.skipTest('Test fails on betawiki; T69931')
mysite = self.get_site()
fwd = list(mysite.alllinks(total=10))
@@ -876,7 +876,7 @@
'gqpspecialpage-cantexecute'):
# User must have correct permissions to use
# Special:UnwatchedPages
- raise unittest.SkipTest(error)
+ self.skipTest(error)
raise
# Make sure each object returned by site.unwatchedpages() is a
@@ -987,7 +987,7 @@
def test_protectedpages_create(self):
"""Test that protectedpages returns protected page titles."""
if self.site.mw_version < '1.15':
- raise unittest.SkipTest('requires v1.15+')
+ self.skipTest('requires v1.15+')
pages = list(self.get_site().protectedpages(type='create', total=10))
for page in pages:
@@ -1015,8 +1015,9 @@
if list(site.protectedpages(type='edit', level=level, total=1)):
levels.add(level)
if not levels:
- raise unittest.SkipTest('The site "{0}" has no protected pages in '
- 'main namespace.'.format(site))
+ self.skipTest(
+ 'The site "{0}" has no protected pages in main namespace.'
+ .format(site))
# select one level which won't yield all pages from above
level = next(iter(levels))
if len(levels) == 1:
@@ -1034,7 +1035,7 @@
def test_pages_with_property(self):
"""Test pages_with_property method."""
if self.site.mw_version < '1.21':
- raise unittest.SkipTest('requires v1.21+')
+ self.skipTest('requires v1.21+')
mysite = self.get_site()
pnames = mysite.get_property_names()
for item in ('defaultsort', 'disambiguation', 'displaytitle',
@@ -1054,7 +1055,7 @@
def test_unconnected(self):
"""Test site.unconnected_pages method."""
if not self.site.data_repository():
- raise unittest.SkipTest('Site is not using a Wikibase repository')
+ self.skipTest('Site is not using a Wikibase repository')
upgen = self.site.unconnected_pages(total=3)
self.assertDictEqual(
upgen.request._params, {
@@ -1156,7 +1157,7 @@
"""Skip tests if Linter extension is missing."""
super(TestLinterPages, self).setUp()
if not self.site.has_extension('Linter'):
- raise unittest.SkipTest(
+ self.skipTest(
'The site {0} does not use Linter extension'.format(self.site))
def test_linter_pages(self):
@@ -1366,7 +1367,7 @@
try:
self.assertIn(entry[0].namespace(), [2, 3])
except HiddenKeyError as e:
- raise unittest.SkipTest(
+ self.skipTest(
'Log entry {entry} is hidden:\n{entry.data}\n{error!r}'
.format(entry=entry, error=e))
@@ -1465,7 +1466,7 @@
def test_ns_file(self):
"""Test the site.recentchanges() method with File: and File talk:."""
if self.site.code == 'wikidata':
- raise unittest.SkipTest(
+ self.skipTest(
'MediaWiki bug frequently occurring on Wikidata. T101502')
mysite = self.site
for change in mysite.recentchanges(namespaces=[6, 7], total=5):
@@ -1594,9 +1595,8 @@
"""Skip tests for Wikia Search extension."""
super(SearchTestCase, self).setUp()
if self.site.has_extension('Wikia Search'):
- raise unittest.SkipTest(
- 'The site {!r} does not use MediaWiki search'
- .format(self.site))
+ self.skipTest('The site {!r} does not use MediaWiki search'
+ .format(self.site))
def test_search(self):
"""Test the site.search() method."""
@@ -1622,9 +1622,8 @@
self.assertEqual(hit.namespace(), 0)
except pywikibot.data.api.APIError as e:
if e.code == 'gsrsearch-error' and 'timed out' in e.info:
- raise unittest.SkipTest(
- 'gsrsearch returned timeout on site: {!r}'
- .format(e))
+ self.skipTest('gsrsearch returned timeout on site: {!r}'
+ .format(e))
raise
@suppress_warnings("where='title' is deprecated", DeprecationWarning)
@@ -1653,7 +1652,7 @@
self.assertEqual(hit.namespace(), 0)
except pywikibot.data.api.APIError as e:
if e.code in ('search-title-disabled', 'gsrsearch-title-disabled'):
- raise unittest.SkipTest(
+ self.skipTest(
'Title search disabled on site: {0}'.format(self.site))
raise
@@ -1894,7 +1893,7 @@
for dr in gen:
break
else:
- raise unittest.SkipTest(
+ self.skipTest(
'{0} contains no deleted revisions.'.format(mainpage))
self.assertLessEqual(len(dr['revisions']), 10)
self.assertTrue(all(isinstance(rev, dict)
@@ -2091,7 +2090,7 @@
in ['Jimbo Wales', 'Brion VIBBER', 'Tim Starling'])
cnt += 1
if not cnt:
- raise unittest.SkipTest('Test usernames not found')
+ self.skipTest('Test usernames not found')
class PatrolTestCase(TokenTestBase, TestCase):
@@ -2111,7 +2110,7 @@
rc = list(mysite.recentchanges(total=1))
if not rc:
- raise unittest.SkipTest('no recent changes to patrol')
+ self.skipTest('no recent changes to patrol')
rc = rc[0]
@@ -2121,12 +2120,11 @@
result = list(mysite.patrol(rcid=rc['rcid']))
except api.APIError as error:
if error.code == 'permissiondenied':
- raise unittest.SkipTest(error)
+ self.skipTest(error)
raise
if hasattr(mysite, '_patroldisabled') and mysite._patroldisabled:
- raise unittest.SkipTest('Patrolling is disabled on {} wiki.'
- .format(mysite))
+ self.skipTest('Patrolling is disabled on {} wiki.'.format(mysite))
result = result[0]
self.assertIsInstance(result, dict)
@@ -2140,7 +2138,7 @@
result = list(mysite.patrol(**params))
except api.APIError as error:
if error.code == 'badtoken':
- raise unittest.SkipTest(error)
+ self.skipTest(error)
except pywikibot.Error:
# expected result
pass
@@ -2426,7 +2424,7 @@
def test_siteinfo_v1_16(self):
"""Test v.16+ siteinfo values."""
if self.site.mw_version < '1.16':
- raise unittest.SkipTest('requires v1.16+')
+ self.skipTest('requires v1.16+')
mysite = self.get_site()
self.assertIsInstance(
@@ -3007,7 +3005,7 @@
# for the test to be useful.
link_count = len(list(mysite.pagelinks(mainpage, total=10)))
if link_count < 2:
- raise unittest.SkipTest('insufficient links on main page')
+ self.skipTest('insufficient links on main page')
# get a fresh generator; we now know how many results it will have,
# if it is less than 10.
@@ -3032,7 +3030,7 @@
# for the test to be useful.
link_count = len(list(mysite.pagelinks(mainpage, total=10)))
if link_count < 2:
- raise unittest.SkipTest('insufficient links on main page')
+ self.skipTest('insufficient links on main page')
# get a fresh generator; we now know how many results it will have,
# if it is less than 10.
@@ -3054,7 +3052,7 @@
count = 0
links = list(mysite.pagelinks(mainpage, total=10))
if len(links) < 2:
- raise unittest.SkipTest('insufficient links on main page')
+ self.skipTest('insufficient links on main page')
# change the title of the page, to test sametitle().
# preloadpages will send the page ids, as they have already been loaded
@@ -3083,7 +3081,7 @@
count = 0
links = list(mysite.pagelinks(mainpage, total=10))
if len(links) < 2:
- raise unittest.SkipTest('insufficient links on main page')
+ self.skipTest('insufficient links on main page')
# change the title of the page _and_ delete the pageids.
# preloadpages can only send the titles, and preloadpages should
@@ -3112,7 +3110,7 @@
count = 0
links = list(mysite.pagelinks(mainpage, total=10))
if len(links) < 2:
- raise unittest.SkipTest('insufficient links on main page')
+ self.skipTest('insufficient links on main page')
for page in links:
page._link._text += ' foobar'
diff --git a/tests/tools_tests.py b/tests/tools_tests.py
index ce8722b..f42cc00 100644
--- a/tests/tools_tests.py
+++ b/tests/tools_tests.py
@@ -2,7 +2,7 @@
# -*- coding: utf-8 -*-
"""Test tools package alone which don't fit into other tests."""
#
-# (C) Pywikibot team, 2015-2018
+# (C) Pywikibot team, 2015-2019
#
# Distributed under the terms of the MIT license.
from __future__ import absolute_import, division, unicode_literals
@@ -158,7 +158,7 @@
try:
subprocess.Popen(['7za'], stdout=subprocess.PIPE).stdout.close()
except OSError:
- raise unittest.SkipTest('7za not installed')
+ self.skipTest('7za not installed')
self.assertEqual(
self._get_content(self.base_file + '.7z'), self.original_content)
self.assertRaisesRegex(OSError,
@@ -170,7 +170,7 @@
def test_open_archive_lzma(self):
"""Test open_archive with lzma compressor in the standard library."""
if isinstance(tools.lzma, ImportError):
- raise unittest.SkipTest('lzma not importable')
+ self.skipTest('lzma not importable')
self.assertEqual(
self._get_content(self.base_file + '.lzma'), self.original_content)
# Legacy LZMA container formet has no magic, skipping
@@ -295,7 +295,7 @@
def test_write_archive_lzma(self):
"""Test writing a lzma archive."""
if isinstance(tools.lzma, ImportError):
- raise unittest.SkipTest('lzma not importable')
+ self.skipTest('lzma not importable')
content = self._write_content('.lzma')
with open(self.base_file + '.lzma', 'rb') as f:
@@ -304,7 +304,7 @@
def test_write_archive_xz(self):
"""Test writing a xz archive."""
if isinstance(tools.lzma, ImportError):
- raise unittest.SkipTest('lzma not importable')
+ self.skipTest('lzma not importable')
content = self._write_content('.xz')
self.assertEqual(content[:6], b'\xFD7zXZ\x00')
diff --git a/tests/wikibase_edit_tests.py b/tests/wikibase_edit_tests.py
index ee082d7..69e61e8 100644
--- a/tests/wikibase_edit_tests.py
+++ b/tests/wikibase_edit_tests.py
@@ -6,7 +6,7 @@
class in edit_failiure_tests.py
"""
#
-# (C) Pywikibot team, 2014-2018
+# (C) Pywikibot team, 2014-2019
#
# Distributed under the terms of the MIT license.
#
@@ -245,8 +245,8 @@
# Make sure the wiki supports wikibase-conceptbaseuri
if testsite.mw_version < '1.29.0-wmf.2':
- raise unittest.SkipTest('Wiki version must be 1.29.0-wmf.2 or '
- 'newer to support unbound uncertainties.')
+ self.skipTest('Wiki version must be 1.29.0-wmf.2 or newer to '
+ 'support unbound uncertainties.')
# set new claim
claim = pywikibot.page.Claim(testsite, 'P20480',
@@ -269,8 +269,8 @@
# Make sure the wiki supports unbound uncertainties
if testsite.mw_version < '1.29.0-wmf.2':
- raise unittest.SkipTest('Wiki version must be 1.29.0-wmf.2 or '
- 'newer to support unbound uncertainties.')
+ self.skipTest('Wiki version must be 1.29.0-wmf.2 or newer to '
+ 'support unbound uncertainties.')
# set new claim
claim = pywikibot.page.Claim(testsite, 'P69', datatype='quantity')
@@ -291,8 +291,8 @@
# Make sure the wiki supports wikibase-conceptbaseuri
if testsite.mw_version < '1.28-wmf.23':
- raise unittest.SkipTest('Wiki version must be 1.28-wmf.23 or '
- 'newer to expose wikibase-conceptbaseuri.')
+ self.skipTest('Wiki version must be 1.28-wmf.23 or newer to '
+ 'expose wikibase-conceptbaseuri.')
# set new claim
claim = pywikibot.page.Claim(testsite, 'P69', datatype='quantity')
diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py
index c979a41..1c34a12 100644
--- a/tests/wikibase_tests.py
+++ b/tests/wikibase_tests.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Tests for the Wikidata parts of the page module."""
#
-# (C) Pywikibot team, 2008-2018
+# (C) Pywikibot team, 2008-2019
#
# Distributed under the terms of the MIT license.
#
@@ -517,8 +517,8 @@
def test_WbQuantity_unbound(self):
"""Test WbQuantity for value without bounds."""
if self.version < MediaWikiVersion('1.29.0-wmf.2'):
- raise unittest.SkipTest('Wiki version must be 1.29.0-wmf.2 or '
- 'newer to support unbound uncertainties.')
+ self.skipTest('Wiki version must be 1.29.0-wmf.2 or newer to '
+ 'support unbound uncertainties.')
q = pywikibot.WbQuantity(amount=1234.5, site=self.repo)
self.assertEqual(q.toWikibase(),
{'amount': '+1234.5', 'unit': '1',
@@ -527,8 +527,8 @@
def test_WbQuantity_formatting_unbound(self):
"""Test WbQuantity formatting without bounds."""
if self.version < MediaWikiVersion('1.29.0-wmf.2'):
- raise unittest.SkipTest('Wiki version must be 1.29.0-wmf.2 or '
- 'newer to support unbound uncertainties.')
+ self.skipTest('Wiki version must be 1.29.0-wmf.2 or newer to '
+ 'support unbound uncertainties.')
q = pywikibot.WbQuantity(amount='0.044405586', site=self.repo)
self.assertEqual('%s' % q,
'{\n'
@@ -545,8 +545,8 @@
def test_WbQuantity_fromWikibase_unbound(self):
"""Test WbQuantity.fromWikibase() instantiating without bounds."""
if self.version < MediaWikiVersion('1.29.0-wmf.2'):
- raise unittest.SkipTest('Wiki version must be 1.29.0-wmf.2 or '
- 'newer to support unbound uncertainties.')
+ self.skipTest('Wiki version must be 1.29.0-wmf.2 or newer to '
+ 'support unbound uncertainties.')
q = pywikibot.WbQuantity.fromWikibase({'amount': '+0.0229',
'unit': '1'},
site=self.repo)
@@ -557,8 +557,8 @@
def test_WbQuantity_ItemPage_unit(self):
"""Test WbQuantity with ItemPage unit."""
if self.version < MediaWikiVersion('1.28-wmf.23'):
- raise unittest.SkipTest('Wiki version must be 1.28-wmf.23 or '
- 'newer to expose wikibase-conceptbaseuri.')
+ self.skipTest('Wiki version must be 1.28-wmf.23 or newer to '
+ 'expose wikibase-conceptbaseuri.')
q = pywikibot.WbQuantity(amount=1234, error=1,
unit=pywikibot.ItemPage(self.repo, 'Q712226'))
@@ -570,8 +570,8 @@
def test_WbQuantity_equality(self):
"""Test WbQuantity equality with different unit representations."""
if self.version < MediaWikiVersion('1.28-wmf.23'):
- raise unittest.SkipTest('Wiki version must be 1.28-wmf.23 or '
- 'newer to expose wikibase-conceptbaseuri.')
+ self.skipTest('Wiki version must be 1.28-wmf.23 or newer to '
+ 'expose wikibase-conceptbaseuri.')
a = pywikibot.WbQuantity(
amount=1234, error=1,
diff --git a/tests/wikistats_tests.py b/tests/wikistats_tests.py
index 1d034f2..241e81d 100644
--- a/tests/wikistats_tests.py
+++ b/tests/wikistats_tests.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Test cases for the WikiStats dataset."""
#
-# (C) Pywikibot team, 2014-2018
+# (C) Pywikibot team, 2014-2019
#
# Distributed under the terms of the MIT license.
#
@@ -63,7 +63,7 @@
def test_csv(self):
"""Test CSV."""
if not csv:
- raise unittest.SkipTest('unicodecsv not installed.')
+ self.skipTest('unicodecsv not installed.')
ws = WikiStats()
data = ws.get_dict('wikipedia', 'csv')
self.assertIsInstance(data, dict)
--
To view, visit https://gerrit.wikimedia.org/r/490000
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Id9abf50e697974de48679e69587dcf8989b22ba8
Gerrit-Change-Number: 490000
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dalba <dalba.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: jenkins-bot (75)
jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/489442 )
Change subject: [doc] Update doc strings
......................................................................
[doc] Update doc strings
Change detached from I6207b18b8225f7ddc1349dffe321d93a8bf25b00
Change-Id: Iaa24020ce4f6c2d888a01dba5204a1c6df6bf5a4
---
M pywikibot/family.py
M pywikibot/site.py
2 files changed, 12 insertions(+), 4 deletions(-)
Approvals:
Framawiki: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/family.py b/pywikibot/family.py
index b3276ca..de741d4 100644
--- a/pywikibot/family.py
+++ b/pywikibot/family.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
"""Objects representing MediaWiki families."""
#
-# (C) Pywikibot team, 2004-2018
+# (C) Pywikibot team, 2004-2019
#
# Distributed under the terms of the MIT license.
#
@@ -1139,6 +1139,12 @@
The default value is the one used on Wikimedia Foundation wikis,
but needs to be overridden in the family file for any wiki that
uses a different value.
+
+ @param code: Site code
+ @type code: str
+ @raises KeyError: code is not recognised
+ @return: URL path without ending '/'
+ @rtype str
"""
return '/w'
@@ -1162,10 +1168,12 @@
Prefix uri with port and hostname.
@param code: The site code
+ @type code: str
@param uri: The absolute path after the hostname
+ @type uri: str
@param protocol: The protocol which is used. If None it'll determine
the protocol from the code.
- @return: The full URL
+ @return: The full URL ending with uri
@rtype: str
"""
protocol, host = self._hostname(code, protocol)
diff --git a/pywikibot/site.py b/pywikibot/site.py
index bf135f5..42c74fa 100644
--- a/pywikibot/site.py
+++ b/pywikibot/site.py
@@ -775,8 +775,8 @@
self.__code = self.__family.obsolete[self.__code]
# Note the Site function in __init__ emits a UserWarning
# for this condition, showing the callers file and line no.
- pywikibot.log('Site %s instantiated using code %s'
- % (self, code))
+ pywikibot.log('Site {} instantiated using aliases code of {}'
+ .format(self, code))
else:
# no such language anymore
self.obsolete = True
--
To view, visit https://gerrit.wikimedia.org/r/489442
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Iaa24020ce4f6c2d888a01dba5204a1c6df6bf5a4
Gerrit-Change-Number: 489442
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Framawiki <framawiki(a)tools.wmflabs.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot (75)
Gerrit-CC: Dalba <dalba.wiki(a)gmail.com>