jenkins-bot has submitted this change and it was merged.
Change subject: preserve sortKey exactly when (de)serializing category links
......................................................................
preserve sortKey exactly when (de)serializing category links
an empty sortKey and a null one are not considered the same anymore
- in Category.aslink()
by checking `key` against None
- in textlib.getCategoryLinks()
by making the regex catch empty sortKeys
TestCategoryRearrangement has been introduced to ensure that
the bot doesn't do any undesired changes to the text
Change-Id: Ief9d5f95b37f949d667a0ffd43d79b69d12bd8d7
---
M pywikibot/page.py
M pywikibot/textlib.py
M tests/textlib_tests.py
3 files changed, 22 insertions(+), 2 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/page.py b/pywikibot/page.py
index 3396ed1..c6473bc 100644
--- a/pywikibot/page.py
+++ b/pywikibot/page.py
@@ -1913,7 +1913,7 @@
"""
key = sortKey or self.sortKey
- if key:
+ if key is not None:
titleWithSortKey = '%s|%s' % (self.title(withSection=False),
key)
else:
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index aff70fa..b673616 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -663,7 +663,7 @@
text = removeDisabledParts(text)
catNamespace = '|'.join(site.category_namespaces())
R = re.compile(r'\[\[\s*(?P<namespace>%s)\s*:\s*(?P<catName>.+?)'
- r'(?:\|(?P<sortKey>.+?))?\s*\]\]'
+ r'(?:\|(?P<sortKey>.*))?\s*\]\]'
% catNamespace, re.I)
for match in R.finditer(text):
cat = pywikibot.Category(pywikibot.Link(
diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py
index 837dba8..32771f4 100644
--- a/tests/textlib_tests.py
+++ b/tests/textlib_tests.py
@@ -130,6 +130,26 @@
textlib.categoryFormat(data, self.site))
+class TestCategoryRearrangement(PywikibotTestCase):
+
+ """
+ Tests to ensure that sorting keys are not being lost when
+ using .getCategoryLinks() and .replaceCategoryLinks().
+ """
+
+ @classmethod
+ def setUpClass(cls):
+ cls.site = pywikibot.Site('en', 'wikipedia')
+ cls.old = ('[[Category:Cat1]]%(LS)s[[Category:Cat2|]]%(LS)s'
+ '[[Category:Cat1| ]]%(LS)s[[Category:Cat2|key]]'
+ % {'LS': config.LS})
+
+ def test_replace_category_links(self):
+ cats = textlib.getCategoryLinks(self.old, site=self.site)
+ new = textlib.replaceCategoryLinks(self.old, cats, site=self.site)
+ self.assertEqual(old, new)
+
+
if __name__ == '__main__':
try:
unittest.main()
--
To view, visit https://gerrit.wikimedia.org/r/148082
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ief9d5f95b37f949d667a0ffd43d79b69d12bd8d7
Gerrit-PatchSet: 4
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Make get_test_unconnected_page more robust
......................................................................
Make get_test_unconnected_page more robust
Travis tests are regularly 'red' due to bug 67956. This
changeset should reduce the frequency of this problem by
fetching Talk: pages which should be valid for wikibase
items, but also check 10 of them and return the first
without a wikibase item.
Change-Id: I8df00fb9d492e0d400360031c6088bf4a2f2cf4a
---
M tests/wikibase_tests.py
1 file changed, 5 insertions(+), 2 deletions(-)
Approvals:
Legoktm: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py
index ba91af6..72381fb 100644
--- a/tests/wikibase_tests.py
+++ b/tests/wikibase_tests.py
@@ -27,8 +27,11 @@
# fetch a page which is very likely to be unconnected, which doesnt have
# a generator, and unit tests may be used to test old versions of pywikibot
def get_test_unconnected_page(site):
- gen = pagegenerators.NewpagesPageGenerator(site=site, total=1)
- return next(gen)
+ gen = pagegenerators.NewpagesPageGenerator(site=site, total=10,
+ namespaces=[1, ])
+ for page in gen:
+ if not page.properties().get('wikibase_item'):
+ return page
class TestGeneral(PywikibotTestCase):
--
To view, visit https://gerrit.wikimedia.org/r/148004
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I8df00fb9d492e0d400360031c6088bf4a2f2cf4a
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: page.categories() is no longer preferred to texlib.getCategoryLinks()
......................................................................
page.categories() is no longer preferred to texlib.getCategoryLinks()
the former uses the API, while the latter parses wikitext.
Change-Id: Ib87befc2f5dfa9002499758c1414122d5a88f47e
---
M pywikibot/textlib.py
1 file changed, 2 insertions(+), 2 deletions(-)
Approvals:
John Vandenberg: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index 64dbf3c..3ac4aeb 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -649,8 +649,8 @@
def getCategoryLinks(text, site=None):
"""Return a list of category links found in text.
- List contains Category objects.
- Do not call this routine directly, use Page.categories() instead.
+ @return: all category links found
+ @returntype: list of Category objects
"""
result = []
--
To view, visit https://gerrit.wikimedia.org/r/147910
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ib87befc2f5dfa9002499758c1414122d5a88f47e
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Nullzero <nullzero.free(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Pass pep257 on some of the files
......................................................................
Pass pep257 on some of the files
Using flake8-docstrings. The files are not 100% compliant.
Change-Id: I03f9cf80cea01823da332ddf6c3e0d23633cc21d
---
M pywikibot/__init__.py
M pywikibot/bot.py
2 files changed, 56 insertions(+), 34 deletions(-)
Approvals:
Ricordisamoa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index b8cc7c5..848b05a 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -64,7 +64,7 @@
return cls.strptime(ts, cls.mediawikiTSFormat)
def toISOformat(self):
- """Convert the Timestamp object to an ISO 8601 timestamp"""
+ """Convert the Timestamp object to an ISO 8601 timestamp."""
return self.strftime(self.ISO8601Format)
def totimestampformat(self):
@@ -72,7 +72,7 @@
return self.strftime(self.mediawikiTSFormat)
def __str__(self):
- """Return a string format recognized by the API"""
+ """Return a string format recognized by the API."""
return self.toISOformat()
def __add__(self, other):
@@ -98,12 +98,16 @@
"""
Class for handling and storing Coordinates.
+
For now its just being used for DataSite, but
in the future we can use it for the GeoData extension.
"""
+
def __init__(self, lat, lon, alt=None, precision=None, globe='earth',
typ="", name="", dim=None, site=None, entity=''):
"""
+ Represent a geo coordinate.
+
@param lat: Latitude
@type lat: float
@param lon: Longitude
@@ -153,9 +157,9 @@
def toWikibase(self):
"""
- Function which converts the data to a JSON object
- for the Wikibase API.
- FIXME Should this be in the DataSite object?
+ Export the data to a JSON object for the Wikibase API.
+
+ FIXME: Should this be in the DataSite object?
"""
if self.globe not in self.site.globes():
raise CoordinateGlobeUnknownException(u"%s is not supported in Wikibase yet." % self.globe)
@@ -168,7 +172,7 @@
@staticmethod
def fromWikibase(data, site):
- """Constructor to create an object from Wikibase's JSON output"""
+ """Constructor to create an object from Wikibase's JSON output."""
globes = {}
for k in site.globes():
globes[site.globes()[k]] = k
@@ -206,7 +210,7 @@
return self._precision
def precisionToDim(self):
- """Convert precision from Wikibase to GeoData's dim"""
+ """Convert precision from Wikibase to GeoData's dim."""
raise NotImplementedError
@@ -220,9 +224,10 @@
def __init__(self, year=None, month=None, day=None, hour=None, minute=None, second=None, precision=None, before=0,
after=0, timezone=0, calendarmodel=None, site=None):
"""
- Creates a new WbTime object. The precision can be set
- by the Wikibase int value (0-14) or by a human readable
- string, e.g., 'hour'. If no precision is given, it is set
+ Create a new WbTime object.
+
+ The precision can be set by the Wikibase int value (0-14) or by a human
+ readable string, e.g., 'hour'. If no precision is given, it is set
according to the given time units.
"""
if year is None:
@@ -279,15 +284,18 @@
def toTimestr(self):
"""
- Function which converts the the data to a UTC date/time string
+ Convert the data to a UTC date/time string.
+
+ @return: str
"""
return self.FORMATSTR.format(self.year, self.month, self.day,
self.hour, self.minute, self.second)
def toWikibase(self):
"""
- Function which converts the data to a JSON object
- for the Wikibase API.
+ Convert the data to a JSON object for the Wikibase API.
+
+ @return: dict
"""
json = {'time': self.toTimestr(),
'precision': self.precision,
@@ -318,16 +326,18 @@
class WbQuantity(object):
- """ A Wikibase quantity representation"""
+ """A Wikibase quantity representation."""
def __init__(self, amount, unit=None, error=None):
- """
- Creates a new WbQuantity object. The amount is a number representing
- this quantity. The unit is currently not used (only unit-less
- quantities are supported). The error is a number indicating the
- uncertainty of the amount (e.g. ±1). Alternatively the error can be
- expressed as a tuple, where the first value is the upper error and the
- second is the lower error value.
+ u"""
+ Create a new WbQuantity object.
+
+ @param amount: number representing this quantity
+ @type amount: float
+ @param unit: not used (only unit-less quantities are supported)
+ @param error: the uncertainty of the amount (e.g. ±1)
+ @type error: float, or tuple of two floats, where the first value is
+ the upper error and the second is the lower error value.
"""
if amount is None:
raise ValueError('no amount given')
@@ -347,8 +357,7 @@
def toWikibase(self):
"""
- Function which converts the data to a JSON object
- for the Wikibase API.
+ Convert the data to a JSON object for the Wikibase API.
"""
json = {'amount': self.amount,
'upperBound': self.upperBound,
@@ -398,7 +407,7 @@
def deprecate_arg(old_arg, new_arg):
- """Decorator to declare old_arg deprecated and replace it with new_arg"""
+ """Decorator to declare old_arg deprecated and replace it with new_arg."""
_logger = ""
def decorator(method):
@@ -503,9 +512,9 @@
def showDiff(oldtext, newtext):
"""
Output a string showing the differences between oldtext and newtext.
+
The differences are highlighted (only on compatible systems) to show which
changes were made.
-
"""
# This is probably not portable to non-terminal interfaces....
# For information on difflib, see http://pydoc.org/2.1/difflib.html
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index fc4ed7f..46cd023 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -117,10 +117,12 @@
whether the output to the user's console does.
"""
+
def formatException(self, ei):
- """
+ r"""
Convert exception trace to unicode if necessary.
+ Make sure that the exception trace is converted to unicode:
* our pywikibot.Error traces are encoded in our
console encoding, which is needed for plainly printing them.
* but when it comes to logging using logging.exception,
@@ -186,7 +188,6 @@
Accordingly, do ''not'' use print statements in bot code; instead,
use pywikibot.output function.
"""
-
global _handlers_initialized
moduleName = calledModuleName()
@@ -366,7 +367,7 @@
def output(text, decoder=None, newline=True, toStdout=False, **kwargs):
- """Output a message to the user via the userinterface.
+ r"""Output a message to the user via the userinterface.
Works like print, but uses the encoding used by the user's console
(console_encoding in the configuration file) instead of ASCII.
@@ -756,13 +757,19 @@
def __init__(self, **kwargs):
"""
- Only accepts options defined in availableOptions
+ Only accept options defined in availableOptions.
+
+ @param kwargs: bot options
+ @type kwargs: dict
"""
self.setOptions(**kwargs)
def setOptions(self, **kwargs):
"""
- Sets the instance options
+ Set the instance options.
+
+ @param kwargs: options
+ @type kwargs: dict
"""
# contains the options overriden from defaults
self.options = {}
@@ -780,6 +787,7 @@
def getOption(self, option):
"""
Get the current value of an option.
+
@param option: key defined in Bot.availableOptions
"""
try:
@@ -827,8 +835,9 @@
class WikidataBot:
"""
- Generic Wikidata Bot to be subclassed
- used in claimit.py, coordinate_import.py and harvest_template.py
+ Generic Wikidata Bot to be subclassed.
+
+ Used in claimit.py, coordinate_import.py and harvest_template.py
"""
def cacheSources(self):
@@ -846,8 +855,12 @@
def getSource(self, site):
"""
- Get the source for the specified site,
- if possible
+ Create a Claim usable as a source for Wikibase statements.
+
+ @param site: site that is the source of assertions.
+ @type site: Site
+
+ @return: Claim
"""
if site.family.name in self.source_values and site.code in self.source_values[site.family.name]:
source = pywikibot.Claim(self.repo, 'P143')
--
To view, visit https://gerrit.wikimedia.org/r/145678
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I03f9cf80cea01823da332ddf6c3e0d23633cc21d
Gerrit-PatchSet: 3
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Hashar <hashar(a)free.fr>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Nullzero <nullzero.free(a)gmail.com>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: PEP257 fixes
......................................................................
PEP257 fixes
Change-Id: I37852eb6d9010051dfaeee99eb064417c26e4832
---
M pywikibot/config2.py
1 file changed, 17 insertions(+), 1 deletion(-)
Approvals:
Ricordisamoa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 2f00d57..4527e03 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -1,4 +1,18 @@
# -*- coding: utf-8 -*-
+"""
+Module to define and load pywikibot configuration.
+
+Provides two family class methods which can be used in
+the user-config:
+- register_family_file
+- register_families_folder
+
+Sets module global base_dir and provides utility methods to
+build paths relative to base_dir:
+- makepath
+- datafilepath
+- shortpath
+"""
#
# (C) Rob W.W. Hooft, 2003
# (C) Pywikibot team, 2003-2014
@@ -107,7 +121,7 @@
def _get_base_dir():
- """Return the directory in which user-specific information is stored.
+ r"""Return the directory in which user-specific information is stored.
This is determined in the following order -
1. If the script was called with a -dir: argument, use the directory
@@ -179,6 +193,7 @@
def register_family_file(family_name, file_path):
+ """Register a single family class file."""
usernames[family_name] = {}
sysopnames[family_name] = {}
disambiguation_comment[family_name] = {}
@@ -186,6 +201,7 @@
def register_families_folder(folder_path):
+ """Register all family class files contained in a directory."""
for file_name in os.listdir(folder_path):
if file_name.endswith("_family.py"):
family_name = file_name[:-len("_family.py")]
--
To view, visit https://gerrit.wikimedia.org/r/148018
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I37852eb6d9010051dfaeee99eb064417c26e4832
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Add documentation for config.password_file
......................................................................
Add documentation for config.password_file
The documentation in config2.py in password_file referred the user
to login.py, which did have good documentation, but the basics should
be in the first place that users look: config2.py
Change-Id: I7a450e79f298f9024ac651d2623e99d2a7269c62
---
M pywikibot/config2.py
1 file changed, 6 insertions(+), 3 deletions(-)
Approvals:
Ricordisamoa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 2f00d57..54f5c2e 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -94,10 +94,13 @@
u'species', u'incubator'
]
-# password_file = ".passwd"
-# A password file with default passwords. For more information, please
-# see LoginManager.readPassword in login.py.
# By default you are asked for a password on the terminal.
+# A password file may be used. e.g. password_file = ".passwd"
+# The password file should consist of lines containing
+# Python tuples of any of the following formats:
+# (code, family, username, password)
+# (family, username, password)
+# (username, password)
password_file = None
# edit summary to use if not supplied by bot script
--
To view, visit https://gerrit.wikimedia.org/r/148002
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I7a450e79f298f9024ac651d2623e99d2a7269c62
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Another user-agent related fixup
......................................................................
Another user-agent related fixup
config2 was previously able to be run under python3.
This fixes a recent commit which broke that.
Change-Id: Iec2b9357b09a88cbda61a218d502274179d83da4
---
M pywikibot/config2.py
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Ricordisamoa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 2f00d57..8ef9694 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -173,7 +173,7 @@
for arg in sys.argv[1:]:
if arg.startswith("-verbose") or arg == "-v":
- print "The base directory is %s" % base_dir
+ print("The base directory is %s" % base_dir)
break
family_files = {}
--
To view, visit https://gerrit.wikimedia.org/r/148014
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Iec2b9357b09a88cbda61a218d502274179d83da4
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: textlib InterwikiFormat() depends on config
......................................................................
textlib InterwikiFormat() depends on config
InterwikiFormat implicitly uses Page.title() which by default uses
config settings to dynamically determine whether to include a family and/or
lang prefix to the title. InterwikiFormat is supposed to format
interwikis relative to 'insite', not config variables such as family.
Explicitly invoke Page.title() with appropriate parameters to override
config settings.
The relevant test failed when config.family was not wikipedia.
In addition to the bug in textlib, the test also depended on config
settings. Link()'s should be instantiated with a source in these tests.
Change-Id: I9ab8780e659517db7068d4af3164a2f54ce85461
---
M pywikibot/textlib.py
M tests/textlib_tests.py
2 files changed, 5 insertions(+), 3 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Ricordisamoa: Looks good to me, approved
Legoktm: Looks good to me, but someone else must approve
jenkins-bot: Verified
diff --git a/pywikibot/textlib.py b/pywikibot/textlib.py
index d561b73..289cd89 100644
--- a/pywikibot/textlib.py
+++ b/pywikibot/textlib.py
@@ -604,7 +604,9 @@
s = []
for site in ar:
try:
- link = unicode(links[site]).replace('[[:', '[[')
+ title = links[site].title(asLink=True, forceInterwiki=True,
+ insite=insite)
+ link = title.replace('[[:', '[[')
s.append(link)
except AttributeError:
s.append(getSite(site).linkto(links[site], othersite=insite))
diff --git a/tests/textlib_tests.py b/tests/textlib_tests.py
index 3297c7d..8bfd352 100644
--- a/tests/textlib_tests.py
+++ b/tests/textlib_tests.py
@@ -99,8 +99,8 @@
def test_interwiki_format(self):
interwikis = {
- 'de': pywikibot.Page(pywikibot.Link('de:German')),
- 'fr': pywikibot.Page(pywikibot.Link('fr:French'))
+ 'de': pywikibot.Page(pywikibot.Link('de:German', self.site)),
+ 'fr': pywikibot.Page(pywikibot.Link('fr:French', self.site))
}
self.assertEqual('[[de:German]]%(LS)s[[fr:French]]%(LS)s'
% {'LS': config.LS},
--
To view, visit https://gerrit.wikimedia.org/r/142506
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I9ab8780e659517db7068d4af3164a2f54ce85461
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Legoktm <legoktm.wikipedia(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>
jenkins-bot has submitted this change and it was merged.
Change subject: Fix wikibase tests broken by wiki edit
......................................................................
Fix wikibase tests broken by wiki edit
wikibase:Q5296 English label has changed from 'Main Page'
to 'Wikimedia main page'. Slightly adjust the logic so that either
is acceptable.
The initial version of the wikibase tests included a minor
code issue causing a test to be ineffective. In testWikibase, instead
of exercising item2.labels, item.labels is exercised a second time.
item2.getID does not cause get() to be called, so get() needs to
be explicitly in the test sequence.
Change-Id: I75fa36c3b05ba8141c51ce19575b7667f408fd84
---
M tests/wikibase_tests.py
1 file changed, 3 insertions(+), 2 deletions(-)
Approvals:
John Vandenberg: Looks good to me, but someone else must approve
Ricordisamoa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/tests/wikibase_tests.py b/tests/wikibase_tests.py
index 223c5b3..ba91af6 100644
--- a/tests/wikibase_tests.py
+++ b/tests/wikibase_tests.py
@@ -42,13 +42,14 @@
self.assertEqual(item.getID(), 'Q5296')
self.assertEqual(item.title(), 'Q5296')
self.assertTrue('en' in item.labels)
- self.assertEqual(item.labels['en'], 'Main Page')
+ self.assertTrue(item.labels['en'].lower().endswith('main page'))
self.assertTrue('en' in item.aliases)
self.assertTrue('HomePage' in item.aliases['en'])
self.assertEqual(item.namespace(), 0)
item2 = pywikibot.ItemPage(repo, 'q5296')
self.assertEqual(item2.getID(), 'Q5296')
- self.assertEqual(item.labels['en'], 'Main Page')
+ item2.get()
+ self.assertTrue(item2.labels['en'].lower().endswith('main page'))
prop = pywikibot.PropertyPage(repo, 'Property:P21')
self.assertEqual(prop.type, 'wikibase-item')
self.assertEqual(prop.namespace(), 120)
--
To view, visit https://gerrit.wikimedia.org/r/147897
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I75fa36c3b05ba8141c51ce19575b7667f408fd84
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ricordisamoa <ricordisamoa(a)openmailbox.org>
Gerrit-Reviewer: jenkins-bot <>