~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

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

  • Committer: Martin Pool
  • Date: 2006-06-20 03:30:14 UTC
  • mfrom: (1793 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1797.
  • Revision ID: mbp@sourcefrog.net-20060620033014-e19ce470e2ce6561
[merge] bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
32
31
import bzrlib.branch
33
32
from bzrlib.builtins import merge
36
35
from bzrlib.osutils import pathjoin
37
36
from bzrlib.revisionspec import RevisionSpec
38
37
from bzrlib.status import show_tree_status
39
 
from bzrlib.tests import TestCaseWithTransport
 
38
from bzrlib.tests import TestCaseWithTransport, TestSkipped
40
39
from bzrlib.workingtree import WorkingTree
41
40
 
42
41
 
219
218
        self.assertEquals(result2, result)
220
219
 
221
220
 
 
221
class TestStatusEncodings(TestCaseWithTransport):
 
222
    
 
223
    def setUp(self):
 
224
        TestCaseWithTransport.setUp(self)
 
225
        self.user_encoding = bzrlib.user_encoding
 
226
        self.stdout = sys.stdout
 
227
 
 
228
    def tearDown(self):
 
229
        bzrlib.user_encoding = self.user_encoding
 
230
        sys.stdout = self.stdout
 
231
        TestCaseWithTransport.tearDown(self)
 
232
 
 
233
    def make_uncommitted_tree(self):
 
234
        """Build a branch with uncommitted unicode named changes in the cwd."""
 
235
        working_tree = self.make_branch_and_tree(u'.')
 
236
        filename = u'hell\u00d8'
 
237
        try:
 
238
            self.build_tree_contents([(filename, 'contents of hello')])
 
239
        except UnicodeEncodeError:
 
240
            raise TestSkipped("can't build unicode working tree in "
 
241
                "filesystem encoding %s" % sys.getfilesystemencoding())
 
242
        working_tree.add(filename)
 
243
        return working_tree
 
244
 
 
245
    def test_stdout_ascii(self):
 
246
        sys.stdout = StringIO()
 
247
        bzrlib.user_encoding = 'ascii'
 
248
        working_tree = self.make_uncommitted_tree()
 
249
        stdout, stderr = self.run_bzr("status")
 
250
 
 
251
        self.assertEquals(stdout, """\
 
252
added:
 
253
  hell?
 
254
""")
 
255
 
 
256
    def test_stdout_latin1(self):
 
257
        sys.stdout = StringIO()
 
258
        bzrlib.user_encoding = 'latin-1'
 
259
        working_tree = self.make_uncommitted_tree()
 
260
        stdout, stderr = self.run_bzr('status')
 
261
 
 
262
        self.assertEquals(stdout, u"""\
 
263
added:
 
264
  hell\u00d8
 
265
""".encode('latin-1'))
 
266