Merge lp:~jelmer/brz/commit-message-edit-encoding into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Merged at revision: 6840
Proposed branch: lp:~jelmer/brz/commit-message-edit-encoding
Merge into: lp:brz
Diff against target: 49 lines (+17/-2)
1 file modified
breezy/tests/test_msgeditor.py (+17/-2)
To merge this branch: bzr merge lp:~jelmer/brz/commit-message-edit-encoding
Reviewer Review Type Date Requested Status
Martin Packman Approve
Review via email: mp+335000@code.launchpad.net

Description of the change

Support situations where osutils.get_user_encoding doesn't support encoding unicode string.

This fixes running the testsuite e.g. when LC_ALL=POSIX.

To post a comment you must log in.
Revision history for this message
Martin Packman (gz) wrote :

Seems fine, though that's dumb behaviour on Python's part.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'breezy/tests/test_msgeditor.py'
--- breezy/tests/test_msgeditor.py 2017-11-12 13:53:51 +0000
+++ breezy/tests/test_msgeditor.py 2017-12-09 03:07:49 +0000
@@ -40,6 +40,7 @@
40 TestSkipped,40 TestSkipped,
41 multiply_tests,41 multiply_tests,
42 probe_bad_non_ascii,42 probe_bad_non_ascii,
43 probe_unicode_in_user_encoding,
43 split_suite_by_re,44 split_suite_by_re,
44 )45 )
45from .EncodingAdapter import encoding_scenarios46from .EncodingAdapter import encoding_scenarios
@@ -204,7 +205,7 @@
204 os.chmod('fed.py', 0o755)205 os.chmod('fed.py', 0o755)
205 self.overrideEnv('BRZ_EDITOR', './fed.py')206 self.overrideEnv('BRZ_EDITOR', './fed.py')
206207
207 def test_edit_commit_message(self):208 def test_edit_commit_message_without_infotext(self):
208 working_tree = self.make_uncommitted_tree()209 working_tree = self.make_uncommitted_tree()
209 self.make_fake_editor()210 self.make_fake_editor()
210211
@@ -212,13 +213,27 @@
212 self.assertEqual('test message from fed\n',213 self.assertEqual('test message from fed\n',
213 msgeditor.edit_commit_message(''))214 msgeditor.edit_commit_message(''))
214215
216 def test_edit_commit_message_with_ascii_infotext(self):
217 working_tree = self.make_uncommitted_tree()
218 self.make_fake_editor()
219
215 mutter('edit_commit_message with ascii string infotext')220 mutter('edit_commit_message with ascii string infotext')
216 self.assertEqual('test message from fed\n',221 self.assertEqual('test message from fed\n',
217 msgeditor.edit_commit_message('spam'))222 msgeditor.edit_commit_message('spam'))
218223
224 def test_edit_commit_message_with_unicode_infotext(self):
225 working_tree = self.make_uncommitted_tree()
226 self.make_fake_editor()
227
219 mutter('edit_commit_message with unicode infotext')228 mutter('edit_commit_message with unicode infotext')
229 uni_val, ue_val = probe_unicode_in_user_encoding()
230 if ue_val is None:
231 raise TestSkipped(
232 'Cannot find a unicode character that works in encoding %s'
233 % (osutils.get_user_encoding(),))
234
220 self.assertEqual('test message from fed\n',235 self.assertEqual('test message from fed\n',
221 msgeditor.edit_commit_message(u'\u1234'))236 msgeditor.edit_commit_message(uni_val))
222237
223 tmpl = edit_commit_message_encoded(u'\u1234'.encode("utf8"))238 tmpl = edit_commit_message_encoded(u'\u1234'.encode("utf8"))
224 self.assertEqual('test message from fed\n', tmpl)239 self.assertEqual('test message from fed\n', tmpl)

Subscribers

People subscribed via source and target branches