← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:py3-git-translatePath-bytestring into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:py3-git-translatePath-bytestring into launchpad:master.

Commit message:
Adjust TestGitAPI.test_translatePath_create_bytestring for Python 3

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/398785

The issue of ASCII strings coming in as byte strings only applies on Python 2 (and possibly not even there now that turnip runs on Python 3, but never mind that for now), and is really about native strings.  Fix the test to avoid a spurious failure on Python 3.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-git-translatePath-bytestring into launchpad:master.
diff --git a/lib/lp/code/xmlrpc/tests/test_git.py b/lib/lp/code/xmlrpc/tests/test_git.py
index 0a6f5c6..e226038 100644
--- a/lib/lp/code/xmlrpc/tests/test_git.py
+++ b/lib/lp/code/xmlrpc/tests/test_git.py
@@ -1358,13 +1358,13 @@ class TestGitAPI(TestGitAPIMixin, TestCaseWithFactory):
         team = self.factory.makeTeam(members=[requester])
         self.assertCreates(requester, u"/~%s/+git/random" % team.name)
 
-    def test_translatePath_create_bytestring(self):
-        # ASCII strings come in as bytestrings, not Unicode strings. They
-        # work fine too.
+    def test_translatePath_create_native_string(self):
+        # On Python 2, ASCII strings come in as native strings, not Unicode
+        # strings. They work fine too.
         requester = self.factory.makePerson()
         project = self.factory.makeProduct()
         path = u"/~%s/%s/+git/random" % (requester.name, project.name)
-        self.assertCreates(requester, path.encode('ascii'))
+        self.assertCreates(requester, six.ensure_str(path))
 
     def test_translatePath_anonymous_cannot_create(self):
         # Anonymous users cannot create repositories.