/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

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

  • Committer: John Arbash Meinel
  • Date: 2006-01-06 03:40:32 UTC
  • mto: (1685.1.1 bzr-encoding)
  • mto: This revision was merged to the branch mainline in revision 1752.
  • Revision ID: john@arbash-meinel.com-20060106034032-6ad5e572d9249519
Moved run_bzr_decode into TestCase
Added a new test for Command.encoding_type
added tests for bzr revno and bzr revision-info

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2005 by Canonical Ltd
 
1
# Copyright (C) 2006 by Canonical Ltd
2
2
# -*- coding: utf-8 -*-
3
3
 
4
4
# This program is free software; you can redistribute it and/or modify
57
57
        open('b', 'wb').write(_shrimp_sandwich.encode('utf-8') + '\n')
58
58
        bzr('add', 'b')
59
59
        bzr('commit', '-m', u'Creating a ' + _shrimp_sandwich)
60
 
        # TODO: jam 20050105 Handle the case where we can't create a
 
60
        # TODO: jam 20060105 Handle the case where we can't create a
61
61
        #       unicode filename on the current filesytem. I don't know
62
62
        #       what exception would be raised, because all of my
63
63
        #       filesystems support it. :)
74
74
                del os.environ['BZREMAIL']
75
75
        super(TestNonAscii, self).tearDown()
76
76
 
77
 
    def bzr(self, *args, **kwargs):
78
 
        if kwargs.has_key('encoding'):
79
 
            encoding = kwargs['encoding']
80
 
        else:
81
 
            encoding = bzrlib.user_encoding
82
 
        return self.run_bzr(*args, **kwargs)[0].decode(encoding)
83
 
 
84
77
    def test_log(self):
85
 
        txt = self.bzr('log')
 
78
        bzr = self.run_bzr_decode
 
79
 
 
80
        txt = bzr('log')
86
81
        self.assertNotEqual(-1, txt.find(_erik))
87
82
        self.assertNotEqual(-1, txt.find(_shrimp_sandwich))
88
83
 
89
 
        txt = self.bzr('log', '--verbose')
 
84
        txt = bzr('log', '--verbose')
90
85
        self.assertNotEqual(-1, txt.find(_juju))
91
86
 
92
87
        # Make sure log doesn't fail even if we can't write out
93
 
        txt = self.bzr('log', '--verbose', encoding='ascii')
 
88
        txt = bzr('log', '--verbose', encoding='ascii')
94
89
        self.assertEqual(-1, txt.find(_juju))
95
90
        self.assertNotEqual(-1, txt.find(_juju.encode('ascii', 'replace')))
96
91
 
97
92
    def test_ls(self):
98
 
        txt = self.bzr('ls')
 
93
        bzr = self.run_bzr_decode
 
94
 
 
95
        txt = bzr('ls')
99
96
        self.assertEqual(['a', 'b', u'\u062c\u0648\u062c\u0648.txt'],
100
97
                         txt.splitlines())
101
 
        txt = self.bzr('ls', '--null')
 
98
        txt = bzr('ls', '--null')
102
99
        self.assertEqual(['a', 'b', u'\u062c\u0648\u062c\u0648.txt', ''],
103
100
                         txt.split('\0'))
104
101
 
105
 
        txt = self.bzr('ls', encoding='ascii', retcode=3)
106
 
        txt = self.bzr('ls', '--null', encoding='ascii', retcode=3)
 
102
        txt = bzr('ls', encoding='ascii', retcode=3)
 
103
        txt = bzr('ls', '--null', encoding='ascii', retcode=3)
107
104
 
108
105
    def test_status(self):
 
106
        bzr = self.run_bzr_decode
 
107
 
109
108
        open(_juju + '.txt', 'ab').write('added something\n')
110
 
        txt = self.bzr('status')
 
109
        txt = bzr('status')
111
110
        self.assertEqual(u'modified:\n  \u062c\u0648\u062c\u0648.txt\n' , txt)
112
111
 
113
112
    def test_cat(self):
120
119
        self.assertEqual('arabic filename\n', txt)
121
120
 
122
121
    def test_cat_revision(self):
123
 
        txt = self.bzr('cat-revision', '-r', '1')
 
122
        bzr = self.run_bzr_decode
 
123
 
 
124
        txt = bzr('cat-revision', '-r', '1')
124
125
        self.assertNotEqual(-1, txt.find(_erik))
125
126
 
126
 
        txt = self.bzr('cat-revision', '-r', '2')
 
127
        txt = bzr('cat-revision', '-r', '2')
127
128
        self.assertNotEqual(-1, txt.find(_shrimp_sandwich))
128
129
 
129
130
    def test_mkdir(self):
130
 
        txt = self.bzr('mkdir', _shrimp_sandwich)
 
131
        bzr = self.run_bzr_decode
 
132
 
 
133
        txt = bzr('mkdir', _shrimp_sandwich)
131
134
        self.assertEqual('added ' + _shrimp_sandwich + '\n', txt)
132
135
 
133
136
    def test_relpath(self):
134
 
        txt = self.bzr('relpath', _shrimp_sandwich)
 
137
        bzr = self.run_bzr_decode
 
138
 
 
139
        txt = bzr('relpath', _shrimp_sandwich)
135
140
        self.assertEqual(_shrimp_sandwich + '\n', txt)
136
141
 
137
 
        # TODO: jam 20050106 if relpath can return a munged string
 
142
        # TODO: jam 20060106 if relpath can return a munged string
138
143
        #       this text needs to be fixed
139
 
        self.bzr('relpath', _shrimp_sandwich, encoding='ascii',
 
144
        bzr('relpath', _shrimp_sandwich, encoding='ascii',
140
145
                 retcode=3)
141
146
 
142
147
    def test_inventory(self):
143
 
        txt = self.bzr('inventory')
 
148
        bzr = self.run_bzr_decode
 
149
 
 
150
        txt = bzr('inventory')
144
151
        self.assertEqual(['a', 'b', u'\u062c\u0648\u062c\u0648.txt'],
145
152
                         txt.splitlines())
146
153
 
147
154
        # inventory should fail if unable to encode
148
 
        self.bzr('inventory', encoding='ascii', retcode=3)
 
155
        bzr('inventory', encoding='ascii', retcode=3)
149
156
 
150
157
        # We don't really care about the ids themselves,
151
158
        # but the command shouldn't fail
152
 
        txt = self.bzr('inventory', '--show-ids')
153
 
 
 
159
        txt = bzr('inventory', '--show-ids')
 
160
 
 
161
    def test_revno(self):
 
162
        # There isn't a lot to test here, since revno should always
 
163
        # be an integer
 
164
        bzr = self.run_bzr_decode
 
165
 
 
166
        self.assertEqual('3\n', bzr('revno'))
 
167
 
 
168
    def test_revision_info(self):
 
169
        bzr = self.run_bzr_decode
 
170
 
 
171
        bzr('revision-info', '-r', '1')
 
172
 
 
173
        # TODO: jam 20060105 We have no revisions with non-ascii characters.
 
174
        bzr('revision-info', '-r', '1', encoding='ascii')