~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/blackbox/test_conflicts.py

  • Committer: Martin
  • Date: 2011-05-21 16:29:38 UTC
  • mto: This revision was merged to the branch mainline in revision 5907.
  • Revision ID: gzlist@googlemail.com-20110521162938-1vrw3hp0197l3vrl
Add tests for non-ascii conflict serialisation

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006, 2007, 2009, 2010 Canonical Ltd
 
1
# Copyright (C) 2006, 2007, 2009, 2010, 2011 Canonical Ltd
2
2
#
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
21
21
    )
22
22
from bzrlib.tests import script
23
23
 
 
24
 
24
25
def make_tree_with_conflicts(test, this_path='this', other_path='other',
25
26
        prefix='my'):
26
27
    this_tree = test.make_branch_and_tree(this_path)
80
81
Path conflict: mydir3 / mydir2
81
82
Text conflict in myfile
82
83
""")
 
84
 
 
85
 
 
86
class TestUnicodePaths(tests.TestCaseWithTransport):
 
87
    """Unicode characters in conflicts should be displayed properly"""
 
88
 
 
89
    encoding = "UTF-8"
 
90
 
 
91
    def _as_output(self, text):
 
92
        return text
 
93
 
 
94
    def test_messages(self):
 
95
        """Conflict messages involving non-ascii paths are displayed okay"""
 
96
        make_tree_with_conflicts(self, "branch", prefix=u"\xA7")
 
97
        out, err = self.run_bzr(["conflicts", "-d", "branch"],
 
98
            encoding=self.encoding)
 
99
        self.assertEqual(out.decode(self.encoding),
 
100
            u"Text conflict in \xA7_other_file\n"
 
101
            u"Path conflict: \xA7dir3 / \xA7dir2\n"
 
102
            u"Text conflict in \xA7file\n")
 
103
        self.assertEqual(err, "")
 
104
 
 
105
    def test_text_conflict_paths(self):
 
106
        """Text conflicts on non-ascii paths are displayed okay"""
 
107
        make_tree_with_conflicts(self, "branch", prefix=u"\xA7")
 
108
        out, err = self.run_bzr(["conflicts", "-d", "branch", "--text"],
 
109
            encoding=self.encoding)
 
110
        self.assertEqual(out.decode(self.encoding),
 
111
            u"\xA7_other_file\n"
 
112
            u"\xA7file\n")
 
113
        self.assertEqual(err, "")
 
114
 
 
115
 
 
116
class TestUnicodePathsOnAsciiTerminal(TestUnicodePaths):
 
117
    """Undisplayable unicode characters in conflicts should be escaped"""
 
118
 
 
119
    encoding = "ascii"
 
120
 
 
121
    def setUp(self):
 
122
        self.skip("Need to decide if replacing is the desired behaviour")
 
123
 
 
124
    def _as_output(self, text):
 
125
        return text.encode(self.encoding, "replace")