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},
pywikibot-commits@lists.wikimedia.org