John Vandenberg has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/142506

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(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/06/142506/1

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: newchange
Gerrit-Change-Id: I9ab8780e659517db7068d4af3164a2f54ce85461
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <jay...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to