~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_status.py

Merge from mbp.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
"""
22
22
 
23
23
 
 
24
from cStringIO import StringIO
 
25
from os import mkdir
 
26
from tempfile import TemporaryFile
 
27
import codecs
 
28
 
24
29
from bzrlib.tests import TestCaseInTempDir
25
30
from bzrlib.revisionspec import RevisionSpec
26
31
from bzrlib.merge import merge
27
 
from cStringIO import StringIO
28
32
from bzrlib.status import show_status
29
33
from bzrlib.branch import Branch
30
 
from os import mkdir
31
34
from bzrlib.clone import copy_branch
32
35
 
33
36
class BranchStatus(TestCaseInTempDir):
34
37
    
35
38
    def test_branch_status(self): 
36
39
        """Test basic branch status"""
37
 
        from cStringIO import StringIO
38
40
        from bzrlib.status import show_status
39
41
        from bzrlib.branch import Branch
40
42
        
41
 
        b = Branch.initialize('.')
 
43
        b = Branch.initialize(u'.')
42
44
 
43
45
        # status with nothing
44
46
        tof = StringIO()
61
63
    def test_branch_status_revisions(self):
62
64
        """Tests branch status with revisions"""
63
65
        
64
 
        b = Branch.initialize('.')
 
66
        b = Branch.initialize(u'.')
65
67
 
66
68
        tof = StringIO()
67
69
        self.build_tree(['hello.c', 'bye.c'])
97
99
                           '  hello.c\n'])
98
100
 
99
101
    def status_string(self, branch):
100
 
        tof = StringIO()
 
102
        # use a real file rather than StringIO because it doesn't handle
 
103
        # Unicode very well.
 
104
        tof = codecs.getwriter('utf-8')(TemporaryFile())
101
105
        show_status(branch, to_file=tof)
102
106
        tof.seek(0)
103
 
        return tof.getvalue()
 
107
        return tof.read().decode('utf-8')
104
108
 
105
109
    def test_pending(self):
106
 
        """Pending merges display works"""
 
110
        """Pending merges display works, including Unicode"""
107
111
        mkdir("./branch")
108
112
        b = Branch.initialize('./branch')
109
113
        b.working_tree().commit("Empty commit 1")
110
114
        b_2 = copy_branch(b, './copy')
111
 
        b.working_tree().commit("Empty commit 2")
 
115
        b.working_tree().commit(u"\N{TIBETAN DIGIT TWO} Empty commit 2")
112
116
        merge(["./branch", -1], [None, None], this_dir = './copy')
113
117
        message = self.status_string(b_2)
114
118
        self.assert_(message.startswith("pending merges:\n"))
115
119
        self.assert_(message.endswith("Empty commit 2\n")) 
116
120
        b_2.working_tree().commit("merged")
117
121
        # must be long to make sure we see elipsis at the end
118
 
        b.working_tree().commit("Empty commit 3 blah blah blah blah blah blah blah blah blah"
119
 
                 " blah blah blah blah blah blah bleh")
 
122
        b.working_tree().commit("Empty commit 3 " + 
 
123
                                "blah blah blah blah " * 10)
120
124
        merge(["./branch", -1], [None, None], this_dir = './copy')
121
125
        message = self.status_string(b_2)
122
126
        self.assert_(message.startswith("pending merges:\n"))
129
133
        from bzrlib.status import show_status
130
134
        from bzrlib.branch import Branch
131
135
        
132
 
        b = Branch.initialize('.')
 
136
        b = Branch.initialize(u'.')
133
137
 
134
138
        self.build_tree(['directory/','directory/hello.c', 'bye.c','test.c','dir2/'])
135
139
        b.working_tree().add('directory')