57
57
open('b', 'wb').write(_shrimp_sandwich.encode('utf-8') + '\n')
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()
77
def bzr(self, *args, **kwargs):
78
if kwargs.has_key('encoding'):
79
encoding = kwargs['encoding']
81
encoding = bzrlib.user_encoding
82
return self.run_bzr(*args, **kwargs)[0].decode(encoding)
84
77
def test_log(self):
78
bzr = self.run_bzr_decode
86
81
self.assertNotEqual(-1, txt.find(_erik))
87
82
self.assertNotEqual(-1, txt.find(_shrimp_sandwich))
89
txt = self.bzr('log', '--verbose')
84
txt = bzr('log', '--verbose')
90
85
self.assertNotEqual(-1, txt.find(_juju))
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')))
93
bzr = self.run_bzr_decode
99
96
self.assertEqual(['a', 'b', u'\u062c\u0648\u062c\u0648.txt'],
101
txt = self.bzr('ls', '--null')
98
txt = bzr('ls', '--null')
102
99
self.assertEqual(['a', 'b', u'\u062c\u0648\u062c\u0648.txt', ''],
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)
108
105
def test_status(self):
106
bzr = self.run_bzr_decode
109
108
open(_juju + '.txt', 'ab').write('added something\n')
110
txt = self.bzr('status')
111
110
self.assertEqual(u'modified:\n \u062c\u0648\u062c\u0648.txt\n' , txt)
113
112
def test_cat(self):
120
119
self.assertEqual('arabic filename\n', txt)
122
121
def test_cat_revision(self):
123
txt = self.bzr('cat-revision', '-r', '1')
122
bzr = self.run_bzr_decode
124
txt = bzr('cat-revision', '-r', '1')
124
125
self.assertNotEqual(-1, txt.find(_erik))
126
txt = self.bzr('cat-revision', '-r', '2')
127
txt = bzr('cat-revision', '-r', '2')
127
128
self.assertNotEqual(-1, txt.find(_shrimp_sandwich))
129
130
def test_mkdir(self):
130
txt = self.bzr('mkdir', _shrimp_sandwich)
131
bzr = self.run_bzr_decode
133
txt = bzr('mkdir', _shrimp_sandwich)
131
134
self.assertEqual('added ' + _shrimp_sandwich + '\n', txt)
133
136
def test_relpath(self):
134
txt = self.bzr('relpath', _shrimp_sandwich)
137
bzr = self.run_bzr_decode
139
txt = bzr('relpath', _shrimp_sandwich)
135
140
self.assertEqual(_shrimp_sandwich + '\n', txt)
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',
142
147
def test_inventory(self):
143
txt = self.bzr('inventory')
148
bzr = self.run_bzr_decode
150
txt = bzr('inventory')
144
151
self.assertEqual(['a', 'b', u'\u062c\u0648\u062c\u0648.txt'],
145
152
txt.splitlines())
147
154
# inventory should fail if unable to encode
148
self.bzr('inventory', encoding='ascii', retcode=3)
155
bzr('inventory', encoding='ascii', retcode=3)
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')
159
txt = bzr('inventory', '--show-ids')
161
def test_revno(self):
162
# There isn't a lot to test here, since revno should always
164
bzr = self.run_bzr_decode
166
self.assertEqual('3\n', bzr('revno'))
168
def test_revision_info(self):
169
bzr = self.run_bzr_decode
171
bzr('revision-info', '-r', '1')
173
# TODO: jam 20060105 We have no revisions with non-ascii characters.
174
bzr('revision-info', '-r', '1', encoding='ascii')