jenkins-bot has submitted this change and it was merged.

Change subject: [TOUCHUP] Properly run the no user test
......................................................................


[TOUCHUP] Properly run the no user test

Originally the username in the test was a str but with 1e54a7d6 this
changed into a unicode and added the u-prefix to the output. That patch
fixed the problem by casting the name into str prior to adding it. But
that defies the usage of %r so this patch tries to solve the problem
properly by not casting ALL names into str but only the tested name.

Using str instead of unicode actually uncovered a bug which is already
fixed by a0a194d5.

Change-Id: I3526cb3b29c76c18b92f80ba810b427d8d757617
---
M pywikibot/data/api.py
M tests/dry_api_tests.py
2 files changed, 4 insertions(+), 2 deletions(-)

Approvals:
  John Vandenberg: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/pywikibot/data/api.py b/pywikibot/data/api.py
index 61b34f0..41d6c82 100644
--- a/pywikibot/data/api.py
+++ b/pywikibot/data/api.py
@@ -1146,7 +1146,7 @@
 
             if ip.is_IP(self.site._userinfo['name']):
                 raise Error(u"API write action attempted as IP %r"
-                            % str(self.site._userinfo['name']))
+                            % self.site._userinfo['name'])
 
             if not self.site.user():
                 pywikibot.warning(
diff --git a/tests/dry_api_tests.py b/tests/dry_api_tests.py
index 82d35af..ab80178 100644
--- a/tests/dry_api_tests.py
+++ b/tests/dry_api_tests.py
@@ -194,7 +194,9 @@
         self.assertRaisesRegex(pywikibot.Error, ' without userinfo',
                                Request, site=site, action='edit')
 
-        site._userinfo = {'name': '1.2.3.4', 'groups': []}
+        # Explicitly using str as the test expects it to be str (without the
+        # u-prefix) in Python 2 and this module is using unicode_literals
+        site._userinfo = {'name': str('1.2.3.4'), 'groups': []}
 
         self.assertRaisesRegex(pywikibot.Error, " as IP '1.2.3.4'",
                                Request, site=site, action='edit')

-- 
To view, visit https://gerrit.wikimedia.org/r/203318
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I3526cb3b29c76c18b92f80ba810b427d8d757617
Gerrit-PatchSet: 2
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>
Gerrit-Reviewer: John Vandenberg <[email protected]>
Gerrit-Reviewer: Ladsgroup <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: XZise <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to