~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2006-08-14 16:16:53 UTC
  • mto: (1946.2.6 reduce-knit-churn)
  • mto: This revision was merged to the branch mainline in revision 1919.
  • Revision ID: john@arbash-meinel.com-20060814161653-54cdcdadcd4e9003
Remove bogus entry from BRANCH.TODO

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# Copyright (C) 2005, 2006 by 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
5
5
# the Free Software Foundation; either version 2 of the License, or
6
6
# (at your option) any later version.
7
 
 
 
7
#
8
8
# This program is distributed in the hope that it will be useful,
9
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
11
# GNU General Public License for more details.
12
 
 
 
12
#
13
13
# You should have received a copy of the GNU General Public License
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
17
 
 
18
17
"""Tests of status command.
19
18
 
20
19
Most of these depend on the particular formatting used.
23
22
interface later, they will be non blackbox tests.
24
23
"""
25
24
 
26
 
 
27
25
from cStringIO import StringIO
 
26
import codecs
28
27
from os import mkdir, chdir
 
28
import sys
29
29
from tempfile import TemporaryFile
30
 
import codecs
31
30
 
 
31
from bzrlib import bzrdir, errors, ignores
32
32
import bzrlib.branch
33
33
from bzrlib.builtins import merge
34
 
import bzrlib.bzrdir as bzrdir
35
 
import bzrlib.errors as errors
36
34
from bzrlib.osutils import pathjoin
37
35
from bzrlib.revisionspec import RevisionSpec
38
36
from bzrlib.status import show_tree_status
39
 
from bzrlib.tests import TestCaseWithTransport
 
37
from bzrlib.tests import TestCaseWithTransport, TestSkipped
40
38
from bzrlib.workingtree import WorkingTree
41
39
 
42
40
 
43
41
class BranchStatus(TestCaseWithTransport):
44
42
    
45
 
    def test_branch_status(self): 
 
43
    def test_branch_status(self):
46
44
        """Test basic branch status"""
47
45
        wt = self.make_branch_and_tree('.')
48
46
        b = wt.branch
49
47
 
 
48
        ignores._set_user_ignores(['./.bazaar'])
 
49
 
50
50
        # status with nothing
51
51
        tof = StringIO()
52
52
        show_tree_status(wt, to_file=tof)
70
70
        wt = self.make_branch_and_tree('.')
71
71
        b = wt.branch
72
72
 
 
73
        ignores._set_user_ignores(['./.bazaar'])
 
74
 
73
75
        tof = StringIO()
74
76
        self.build_tree(['hello.c', 'bye.c'])
75
77
        wt.add('hello.c')
140
142
        wt = self.make_branch_and_tree('.')
141
143
        b = wt.branch
142
144
 
 
145
        ignores._set_user_ignores(['./.bazaar'])
 
146
 
143
147
        self.build_tree(['directory/','directory/hello.c', 'bye.c','test.c','dir2/'])
144
148
        wt.add('directory')
145
149
        wt.add('test.c')
200
204
class TestStatus(TestCaseWithTransport):
201
205
 
202
206
    def test_status(self):
 
207
        ignores._set_user_ignores(['./.bazaar'])
 
208
 
203
209
        self.run_bzr("init")
204
210
        self.build_tree(['hello.txt'])
205
211
        result = self.run_bzr("status")[0]
219
225
        self.assertEquals(result2, result)
220
226
 
221
227
 
 
228
class TestStatusEncodings(TestCaseWithTransport):
 
229
    
 
230
    def setUp(self):
 
231
        TestCaseWithTransport.setUp(self)
 
232
        self.user_encoding = bzrlib.user_encoding
 
233
        self.stdout = sys.stdout
 
234
 
 
235
    def tearDown(self):
 
236
        bzrlib.user_encoding = self.user_encoding
 
237
        sys.stdout = self.stdout
 
238
        TestCaseWithTransport.tearDown(self)
 
239
 
 
240
    def make_uncommitted_tree(self):
 
241
        """Build a branch with uncommitted unicode named changes in the cwd."""
 
242
        working_tree = self.make_branch_and_tree(u'.')
 
243
        filename = u'hell\u00d8'
 
244
        try:
 
245
            self.build_tree_contents([(filename, 'contents of hello')])
 
246
        except UnicodeEncodeError:
 
247
            raise TestSkipped("can't build unicode working tree in "
 
248
                "filesystem encoding %s" % sys.getfilesystemencoding())
 
249
        working_tree.add(filename)
 
250
        return working_tree
 
251
 
 
252
    def test_stdout_ascii(self):
 
253
        sys.stdout = StringIO()
 
254
        bzrlib.user_encoding = 'ascii'
 
255
        working_tree = self.make_uncommitted_tree()
 
256
        stdout, stderr = self.run_bzr("status")
 
257
 
 
258
        self.assertEquals(stdout, """\
 
259
added:
 
260
  hell?
 
261
""")
 
262
 
 
263
    def test_stdout_latin1(self):
 
264
        sys.stdout = StringIO()
 
265
        bzrlib.user_encoding = 'latin-1'
 
266
        working_tree = self.make_uncommitted_tree()
 
267
        stdout, stderr = self.run_bzr('status')
 
268
 
 
269
        self.assertEquals(stdout, u"""\
 
270
added:
 
271
  hell\u00d8
 
272
""".encode('latin-1'))
 
273