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
1=== modified file 'breezy/tests/test_msgeditor.py'
2--- breezy/tests/test_msgeditor.py 2017-11-12 13:53:51 +0000
3+++ breezy/tests/test_msgeditor.py 2017-12-09 03:07:49 +0000
4@@ -40,6 +40,7 @@
5 TestSkipped,
6 multiply_tests,
7 probe_bad_non_ascii,
8+ probe_unicode_in_user_encoding,
9 split_suite_by_re,
10 )
11 from .EncodingAdapter import encoding_scenarios
12@@ -204,7 +205,7 @@
13 os.chmod('fed.py', 0o755)
14 self.overrideEnv('BRZ_EDITOR', './fed.py')
15
16- def test_edit_commit_message(self):
17+ def test_edit_commit_message_without_infotext(self):
18 working_tree = self.make_uncommitted_tree()
19 self.make_fake_editor()
20
21@@ -212,13 +213,27 @@
22 self.assertEqual('test message from fed\n',
23 msgeditor.edit_commit_message(''))
24
25+ def test_edit_commit_message_with_ascii_infotext(self):
26+ working_tree = self.make_uncommitted_tree()
27+ self.make_fake_editor()
28+
29 mutter('edit_commit_message with ascii string infotext')
30 self.assertEqual('test message from fed\n',
31 msgeditor.edit_commit_message('spam'))
32
33+ def test_edit_commit_message_with_unicode_infotext(self):
34+ working_tree = self.make_uncommitted_tree()
35+ self.make_fake_editor()
36+
37 mutter('edit_commit_message with unicode infotext')
38+ uni_val, ue_val = probe_unicode_in_user_encoding()
39+ if ue_val is None:
40+ raise TestSkipped(
41+ 'Cannot find a unicode character that works in encoding %s'
42+ % (osutils.get_user_encoding(),))
43+
44 self.assertEqual('test message from fed\n',
45- msgeditor.edit_commit_message(u'\u1234'))
46+ msgeditor.edit_commit_message(uni_val))
47
48 tmpl = edit_commit_message_encoded(u'\u1234'.encode("utf8"))
49 self.assertEqual('test message from fed\n', tmpl)

Subscribers

People subscribed via source and target branches