launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #26308
[Merge] ~cjwatson/launchpad:py3-test-getMergeDiff-unpaired-surrogate into launchpad:master
Colin Watson has proposed merging ~cjwatson/launchpad:py3-test-getMergeDiff-unpaired-surrogate into launchpad:master.
Commit message:
Fix test_getMergeDiff_unpaired_surrogate for Python 3
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/398021
Python 3 decodes the input data `"卷。".encode("GBK").decode("UTF-8", errors="replace")` differently from Python 2, but we don't care about exactly how the input data is constructed so we can just hardcode the result of running that on Python 2.
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:py3-test-getMergeDiff-unpaired-surrogate into launchpad:master.
diff --git a/lib/lp/code/model/tests/test_githosting.py b/lib/lp/code/model/tests/test_githosting.py
index 995b4df..2f38c5d 100644
--- a/lib/lp/code/model/tests/test_githosting.py
+++ b/lib/lp/code/model/tests/test_githosting.py
@@ -290,8 +290,11 @@ class TestGitHostingClient(TestCase):
# pygit2 tries to decode the diff as UTF-8 with errors="replace".
# In some cases this can result in unpaired surrogates, which older
# versions of json/simplejson don't like.
- body = json.dumps(
- {"patch": "卷。".encode("GBK").decode("UTF-8", errors="replace")})
+ # This is u"卷。".encode("GBK").decode("UTF-8", errors="replace") on
+ # Python 2. Python 3 decodes this differently, but we don't mind
+ # how we get there as long as the input contains an unpaired
+ # surrogate.
+ body = json.dumps({"patch": "\uFFFD\uD863"})
with self.mockRequests("GET", body=body):
diff = self.client.getMergeDiff("123", "a", "b")
self.assertEqual({"patch": "\uFFFD\uD863"}, diff)