1185.85.24
by John Arbash Meinel
Moved run_bzr_decode into TestCase |
1 |
# Copyright (C) 2006 by Canonical Ltd
|
1185.85.10
by John Arbash Meinel
Adding a test case which uses non-ascii characters for email, filename, and commit message |
2 |
# -*- coding: utf-8 -*-
|
1685.1.76
by Wouter van Heyst
codecleanup |
3 |
#
|
1185.85.10
by John Arbash Meinel
Adding a test case which uses non-ascii characters for email, filename, and commit message |
4 |
# This program is free software; you can redistribute it and/or modify
|
5 |
# it under the terms of the GNU General Public License as published by
|
|
6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
1685.1.76
by Wouter van Heyst
codecleanup |
8 |
#
|
1185.85.10
by John Arbash Meinel
Adding a test case which uses non-ascii characters for email, filename, and commit message |
9 |
# This program is distributed in the hope that it will be useful,
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
1685.1.76
by Wouter van Heyst
codecleanup |
13 |
#
|
1185.85.10
by John Arbash Meinel
Adding a test case which uses non-ascii characters for email, filename, and commit message |
14 |
# You should have received a copy of the GNU General Public License
|
15 |
# along with this program; if not, write to the Free Software
|
|
16 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
17 |
||
1685.1.76
by Wouter van Heyst
codecleanup |
18 |
"""Black-box tests for bzr handling non-ascii characters."""
|
1185.85.10
by John Arbash Meinel
Adding a test case which uses non-ascii characters for email, filename, and commit message |
19 |
|
20 |
import sys |
|
21 |
import os |
|
1685.1.76
by Wouter van Heyst
codecleanup |
22 |
|
1185.85.10
by John Arbash Meinel
Adding a test case which uses non-ascii characters for email, filename, and commit message |
23 |
import bzrlib |
1711.4.9
by John Arbash Meinel
In general, python on win32 needs to use the unicode os api, because bytestream stuff just doesn't work. |
24 |
import bzrlib.osutils as osutils |
1185.85.10
by John Arbash Meinel
Adding a test case which uses non-ascii characters for email, filename, and commit message |
25 |
from bzrlib.tests import TestCaseInTempDir, TestSkipped |
1185.85.41
by John Arbash Meinel
Changing test_non_ascii.py so that it will keep trying even if it can't encode one piece. |
26 |
from bzrlib.trace import mutter, note |
1685.1.45
by John Arbash Meinel
Moved url functions into bzrlib.urlutils |
27 |
import bzrlib.urlutils as urlutils |
1185.85.10
by John Arbash Meinel
Adding a test case which uses non-ascii characters for email, filename, and commit message |
28 |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
29 |
|
1185.85.10
by John Arbash Meinel
Adding a test case which uses non-ascii characters for email, filename, and commit message |
30 |
class TestNonAscii(TestCaseInTempDir): |
1185.85.67
by John Arbash Meinel
Starting work on a test adapter for multiple encodings. |
31 |
"""Test that bzr handles files/committers/etc which are non-ascii."""
|
32 |
||
1185.85.10
by John Arbash Meinel
Adding a test case which uses non-ascii characters for email, filename, and commit message |
33 |
def setUp(self): |
34 |
super(TestNonAscii, self).setUp() |
|
35 |
self._orig_email = os.environ.get('BZREMAIL', None) |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
36 |
self._orig_encoding = bzrlib.user_encoding |
37 |
||
38 |
bzrlib.user_encoding = self.encoding |
|
39 |
email = self.info['committer'] + ' <joe@foo.com>' |
|
40 |
os.environ['BZREMAIL'] = email.encode(bzrlib.user_encoding) |
|
41 |
self.create_base() |
|
42 |
||
43 |
def tearDown(self): |
|
44 |
if self._orig_email is not None: |
|
45 |
os.environ['BZREMAIL'] = self._orig_email |
|
1185.85.41
by John Arbash Meinel
Changing test_non_ascii.py so that it will keep trying even if it can't encode one piece. |
46 |
else: |
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
47 |
if os.environ.get('BZREMAIL', None) is not None: |
48 |
del os.environ['BZREMAIL'] |
|
49 |
bzrlib.user_encoding = self._orig_encoding |
|
50 |
super(TestNonAscii, self).tearDown() |
|
1185.85.10
by John Arbash Meinel
Adding a test case which uses non-ascii characters for email, filename, and commit message |
51 |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
52 |
def create_base(self): |
1185.85.10
by John Arbash Meinel
Adding a test case which uses non-ascii characters for email, filename, and commit message |
53 |
bzr = self.run_bzr |
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
54 |
|
1685.1.57
by Martin Pool
[broken] Skip unicode blackbox tests if not supported by filesystem |
55 |
fs_enc = sys.getfilesystemencoding() |
1711.4.11
by John Arbash Meinel
Skip non_ascii tests that won't write properly to the screen |
56 |
terminal_enc = osutils.get_terminal_encoding() |
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
57 |
fname = self.info['filename'] |
1685.1.57
by Martin Pool
[broken] Skip unicode blackbox tests if not supported by filesystem |
58 |
dir_name = self.info['directory'] |
59 |
for thing in [fname, dir_name]: |
|
60 |
try: |
|
61 |
thing.encode(fs_enc) |
|
62 |
except UnicodeEncodeError: |
|
63 |
raise TestSkipped(('Unable to represent path %r' |
|
1711.4.11
by John Arbash Meinel
Skip non_ascii tests that won't write properly to the screen |
64 |
' in filesystem encoding "%s"') |
1685.1.57
by Martin Pool
[broken] Skip unicode blackbox tests if not supported by filesystem |
65 |
% (thing, fs_enc)) |
1711.4.11
by John Arbash Meinel
Skip non_ascii tests that won't write properly to the screen |
66 |
try: |
67 |
thing.encode(terminal_enc) |
|
68 |
except UnicodeEncodeError: |
|
69 |
raise TestSkipped(('Unable to represent path %r' |
|
70 |
' in terminal encoding "%s"' |
|
71 |
' (even though it is valid in'
|
|
72 |
' filesystem encoding "%s")') |
|
73 |
% (thing, terminal_enc, fs_enc)) |
|
1685.1.74
by Wouter van Heyst
fix nonascii tests to run properly under LANG=C |
74 |
|
75 |
bzr('init') |
|
76 |
open('a', 'wb').write('foo\n') |
|
77 |
bzr('add', 'a') |
|
78 |
bzr('commit', '-m', 'adding a') |
|
79 |
||
80 |
open('b', 'wb').write('non-ascii \xFF\xFF\xFC\xFB\x00 in b\n') |
|
81 |
bzr('add', 'b') |
|
82 |
bzr('commit', '-m', self.info['message']) |
|
83 |
||
1685.1.57
by Martin Pool
[broken] Skip unicode blackbox tests if not supported by filesystem |
84 |
open(fname, 'wb').write('unicode filename\n') |
1185.85.10
by John Arbash Meinel
Adding a test case which uses non-ascii characters for email, filename, and commit message |
85 |
bzr('add', fname) |
1685.1.57
by Martin Pool
[broken] Skip unicode blackbox tests if not supported by filesystem |
86 |
bzr('commit', '-m', u'And a unicode file\n') |
1185.85.66
by John Arbash Meinel
Adding test for swedish |
87 |
|
1185.85.15
by John Arbash Meinel
Updated bzr status, adding test_cat |
88 |
def test_status(self): |
1185.85.24
by John Arbash Meinel
Moved run_bzr_decode into TestCase |
89 |
bzr = self.run_bzr_decode |
90 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
91 |
open(self.info['filename'], 'ab').write('added something\n') |
1185.85.24
by John Arbash Meinel
Moved run_bzr_decode into TestCase |
92 |
txt = bzr('status') |
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
93 |
self.assertEqual(u'modified:\n %s\n' % (self.info['filename'],), txt) |
1185.85.15
by John Arbash Meinel
Updated bzr status, adding test_cat |
94 |
|
1685.1.76
by Wouter van Heyst
codecleanup |
95 |
txt = bzr('status', encoding='ascii') |
96 |
expected = u'modified:\n %s\n' % ( |
|
97 |
self.info['filename'].encode('ascii', 'replace'),) |
|
98 |
self.assertEqual(expected, txt) |
|
99 |
||
1185.85.15
by John Arbash Meinel
Updated bzr status, adding test_cat |
100 |
def test_cat(self): |
101 |
# bzr cat shouldn't change the contents
|
|
102 |
# using run_bzr since that doesn't decode
|
|
103 |
txt = self.run_bzr('cat', 'b')[0] |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
104 |
self.assertEqual('non-ascii \xFF\xFF\xFC\xFB\x00 in b\n', txt) |
1185.85.15
by John Arbash Meinel
Updated bzr status, adding test_cat |
105 |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
106 |
txt = self.run_bzr('cat', self.info['filename'])[0] |
1185.85.41
by John Arbash Meinel
Changing test_non_ascii.py so that it will keep trying even if it can't encode one piece. |
107 |
self.assertEqual('unicode filename\n', txt) |
1185.85.17
by John Arbash Meinel
switching to using the default encoding instead of utf-8 |
108 |
|
109 |
def test_cat_revision(self): |
|
1185.85.24
by John Arbash Meinel
Moved run_bzr_decode into TestCase |
110 |
bzr = self.run_bzr_decode |
111 |
||
1185.85.72
by John Arbash Meinel
Fix some of the tests. |
112 |
committer = self.info['committer'] |
1185.85.24
by John Arbash Meinel
Moved run_bzr_decode into TestCase |
113 |
txt = bzr('cat-revision', '-r', '1') |
1185.85.72
by John Arbash Meinel
Fix some of the tests. |
114 |
self.failUnless(committer in txt, |
115 |
'failed to find %r in %r' % (committer, txt)) |
|
1185.85.17
by John Arbash Meinel
switching to using the default encoding instead of utf-8 |
116 |
|
1185.85.72
by John Arbash Meinel
Fix some of the tests. |
117 |
msg = self.info['message'] |
1185.85.24
by John Arbash Meinel
Moved run_bzr_decode into TestCase |
118 |
txt = bzr('cat-revision', '-r', '2') |
1185.85.72
by John Arbash Meinel
Fix some of the tests. |
119 |
self.failUnless(msg in txt, 'failed to find %r in %r' % (msg, txt)) |
1185.85.18
by John Arbash Meinel
Updated mkdir, added to test_log |
120 |
|
121 |
def test_mkdir(self): |
|
1185.85.24
by John Arbash Meinel
Moved run_bzr_decode into TestCase |
122 |
bzr = self.run_bzr_decode |
123 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
124 |
txt = bzr('mkdir', self.info['directory']) |
125 |
self.assertEqual(u'added %s\n' % self.info['directory'], txt) |
|
126 |
||
127 |
# The text should be garbled, but the command should succeed
|
|
128 |
txt = bzr('mkdir', self.info['directory'] + '2', encoding='ascii') |
|
129 |
expected = u'added %s2\n' % (self.info['directory'],) |
|
130 |
expected = expected.encode('ascii', 'replace') |
|
131 |
self.assertEqual(expected, txt) |
|
1185.85.19
by John Arbash Meinel
Updated bzr relpath |
132 |
|
133 |
def test_relpath(self): |
|
1185.85.24
by John Arbash Meinel
Moved run_bzr_decode into TestCase |
134 |
bzr = self.run_bzr_decode |
135 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
136 |
txt = bzr('relpath', self.info['filename']) |
137 |
self.assertEqual(self.info['filename'] + '\n', txt) |
|
1185.85.19
by John Arbash Meinel
Updated bzr relpath |
138 |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
139 |
bzr('relpath', self.info['filename'], encoding='ascii', retcode=3) |
1185.85.22
by John Arbash Meinel
Updated cmd_inventory. Changing from having each Command request an encoded stdout to providing one before calling run() |
140 |
|
141 |
def test_inventory(self): |
|
1185.85.24
by John Arbash Meinel
Moved run_bzr_decode into TestCase |
142 |
bzr = self.run_bzr_decode |
143 |
||
144 |
txt = bzr('inventory') |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
145 |
self.assertEqual(['a', 'b', self.info['filename']], |
1185.85.22
by John Arbash Meinel
Updated cmd_inventory. Changing from having each Command request an encoded stdout to providing one before calling run() |
146 |
txt.splitlines()) |
147 |
||
1185.85.23
by John Arbash Meinel
Adding more inventory tests. |
148 |
# inventory should fail if unable to encode
|
1185.85.24
by John Arbash Meinel
Moved run_bzr_decode into TestCase |
149 |
bzr('inventory', encoding='ascii', retcode=3) |
1185.85.23
by John Arbash Meinel
Adding more inventory tests. |
150 |
|
151 |
# We don't really care about the ids themselves,
|
|
152 |
# but the command shouldn't fail
|
|
1185.85.24
by John Arbash Meinel
Moved run_bzr_decode into TestCase |
153 |
txt = bzr('inventory', '--show-ids') |
154 |
||
155 |
def test_revno(self): |
|
156 |
# There isn't a lot to test here, since revno should always
|
|
157 |
# be an integer
|
|
158 |
bzr = self.run_bzr_decode |
|
159 |
||
160 |
self.assertEqual('3\n', bzr('revno')) |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
161 |
self.assertEqual('3\n', bzr('revno', encoding='ascii')) |
1185.85.24
by John Arbash Meinel
Moved run_bzr_decode into TestCase |
162 |
|
163 |
def test_revision_info(self): |
|
164 |
bzr = self.run_bzr_decode |
|
165 |
||
166 |
bzr('revision-info', '-r', '1') |
|
167 |
||
1685.1.76
by Wouter van Heyst
codecleanup |
168 |
# TODO: jam 20060105 If we support revisions with non-ascii characters,
|
169 |
# this should be strict and fail.
|
|
1185.85.24
by John Arbash Meinel
Moved run_bzr_decode into TestCase |
170 |
bzr('revision-info', '-r', '1', encoding='ascii') |
1185.85.25
by John Arbash Meinel
updated 'bzr mv' |
171 |
|
172 |
def test_mv(self): |
|
173 |
bzr = self.run_bzr_decode |
|
174 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
175 |
fname1 = self.info['filename'] |
176 |
fname2 = self.info['filename'] + '2' |
|
177 |
dirname = self.info['directory'] |
|
1185.85.26
by John Arbash Meinel
bzr mv should succeed even if it can't display the paths. |
178 |
|
1685.1.76
by Wouter van Heyst
codecleanup |
179 |
# fname1 already exists
|
1185.85.26
by John Arbash Meinel
bzr mv should succeed even if it can't display the paths. |
180 |
bzr('mv', 'a', fname1, retcode=3) |
181 |
||
182 |
txt = bzr('mv', 'a', fname2) |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
183 |
self.assertEqual(u'a => %s\n' % fname2, txt) |
1185.85.26
by John Arbash Meinel
bzr mv should succeed even if it can't display the paths. |
184 |
self.failIfExists('a') |
185 |
self.failUnlessExists(fname2) |
|
1185.85.25
by John Arbash Meinel
updated 'bzr mv' |
186 |
|
187 |
bzr('commit', '-m', 'renamed to non-ascii') |
|
188 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
189 |
bzr('mkdir', dirname) |
190 |
txt = bzr('mv', fname1, fname2, dirname) |
|
191 |
self.assertEqual([u'%s => %s/%s' % (fname1, dirname, fname1), |
|
192 |
u'%s => %s/%s' % (fname2, dirname, fname2)] |
|
1185.85.26
by John Arbash Meinel
bzr mv should succeed even if it can't display the paths. |
193 |
, txt.splitlines()) |
194 |
||
195 |
# The rename should still succeed
|
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
196 |
newpath = u'%s/%s' % (dirname, fname2) |
197 |
txt = bzr('mv', newpath, 'a', encoding='ascii') |
|
1185.85.26
by John Arbash Meinel
bzr mv should succeed even if it can't display the paths. |
198 |
self.failUnlessExists('a') |
1685.1.2
by John Arbash Meinel
Re-enabling the non_ascii tests after fixing trace.py, bzr ignore also does the right thing now |
199 |
self.assertEqual(newpath.encode('ascii', 'replace') + ' => a\n', txt) |
1185.85.26
by John Arbash Meinel
bzr mv should succeed even if it can't display the paths. |
200 |
|
1185.85.27
by John Arbash Meinel
Updated bzr branch and bzr pull |
201 |
def test_branch(self): |
202 |
# We should be able to branch into a directory that
|
|
203 |
# has a unicode name, even if we can't display the name
|
|
204 |
bzr = self.run_bzr_decode |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
205 |
bzr('branch', u'.', self.info['directory']) |
206 |
bzr('branch', u'.', self.info['directory'] + '2', encoding='ascii') |
|
1185.85.27
by John Arbash Meinel
Updated bzr branch and bzr pull |
207 |
|
208 |
def test_pull(self): |
|
209 |
# Make sure we can pull from paths that can't be encoded
|
|
210 |
bzr = self.run_bzr_decode |
|
211 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
212 |
dirname1 = self.info['directory'] |
213 |
dirname2 = self.info['directory'] + '2' |
|
214 |
bzr('branch', '.', dirname1) |
|
215 |
bzr('branch', dirname1, dirname2) |
|
1185.85.27
by John Arbash Meinel
Updated bzr branch and bzr pull |
216 |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
217 |
os.chdir(dirname1) |
1185.85.27
by John Arbash Meinel
Updated bzr branch and bzr pull |
218 |
open('a', 'ab').write('more text\n') |
219 |
bzr('commit', '-m', 'mod a') |
|
220 |
||
1711.4.9
by John Arbash Meinel
In general, python on win32 needs to use the unicode os api, because bytestream stuff just doesn't work. |
221 |
pwd = osutils.getcwd() |
1185.85.27
by John Arbash Meinel
Updated bzr branch and bzr pull |
222 |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
223 |
os.chdir(u'../' + dirname2) |
1185.85.27
by John Arbash Meinel
Updated bzr branch and bzr pull |
224 |
txt = bzr('pull') |
225 |
||
1685.1.37
by John Arbash Meinel
builtins now use urlfordisplay to display nicer paths to the user. |
226 |
self.assertEqual(u'Using saved location: %s/\n' % (pwd,), txt) |
1185.85.27
by John Arbash Meinel
Updated bzr branch and bzr pull |
227 |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
228 |
os.chdir('../' + dirname1) |
1185.85.27
by John Arbash Meinel
Updated bzr branch and bzr pull |
229 |
open('a', 'ab').write('and yet more\n') |
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
230 |
bzr('commit', '-m', 'modifying a by ' + self.info['committer']) |
1185.85.27
by John Arbash Meinel
Updated bzr branch and bzr pull |
231 |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
232 |
os.chdir('../' + dirname2) |
1185.85.27
by John Arbash Meinel
Updated bzr branch and bzr pull |
233 |
# We should be able to pull, even if our encoding is bad
|
234 |
bzr('pull', '--verbose', encoding='ascii') |
|
1185.85.31
by John Arbash Meinel
Updated bzr push, including bringing in the unused --verbose flag. |
235 |
|
236 |
def test_push(self): |
|
237 |
# TODO: Test push to an SFTP location
|
|
238 |
# Make sure we can pull from paths that can't be encoded
|
|
239 |
bzr = self.run_bzr_decode |
|
240 |
||
1685.1.24
by John Arbash Meinel
cmd_push should use URLs throughout. |
241 |
# TODO: jam 20060427 For drastically improving performance, we probably
|
242 |
# could create a local repository, so it wouldn't have to copy
|
|
243 |
# the files around as much.
|
|
244 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
245 |
dirname = self.info['directory'] |
246 |
bzr('push', dirname) |
|
1185.85.31
by John Arbash Meinel
Updated bzr push, including bringing in the unused --verbose flag. |
247 |
|
248 |
open('a', 'ab').write('adding more text\n') |
|
249 |
bzr('commit', '-m', 'added some stuff') |
|
250 |
||
1685.1.76
by Wouter van Heyst
codecleanup |
251 |
# TODO: check the output text is properly encoded
|
1185.85.31
by John Arbash Meinel
Updated bzr push, including bringing in the unused --verbose flag. |
252 |
bzr('push') |
253 |
||
254 |
f = open('a', 'ab') |
|
255 |
f.write('and a bit more: ') |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
256 |
f.write(dirname.encode('utf-8')) |
1185.85.31
by John Arbash Meinel
Updated bzr push, including bringing in the unused --verbose flag. |
257 |
f.write('\n') |
258 |
f.close() |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
259 |
|
260 |
bzr('commit', '-m', u'Added some ' + dirname) |
|
1185.85.31
by John Arbash Meinel
Updated bzr push, including bringing in the unused --verbose flag. |
261 |
bzr('push', '--verbose', encoding='ascii') |
262 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
263 |
bzr('push', '--verbose', dirname + '2') |
1185.85.31
by John Arbash Meinel
Updated bzr push, including bringing in the unused --verbose flag. |
264 |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
265 |
bzr('push', '--verbose', dirname + '3', encoding='ascii') |
1185.85.31
by John Arbash Meinel
Updated bzr push, including bringing in the unused --verbose flag. |
266 |
|
1685.1.24
by John Arbash Meinel
cmd_push should use URLs throughout. |
267 |
bzr('push', '--verbose', '--create-prefix', dirname + '4/' + dirname + '5') |
268 |
bzr('push', '--verbose', '--create-prefix', dirname + '6/' + dirname + '7', encoding='ascii') |
|
269 |
||
1185.85.32
by John Arbash Meinel
Updated bzr renames |
270 |
def test_renames(self): |
271 |
bzr = self.run_bzr_decode |
|
272 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
273 |
fname = self.info['filename'] + '2' |
1185.85.32
by John Arbash Meinel
Updated bzr renames |
274 |
bzr('mv', 'a', fname) |
275 |
txt = bzr('renames') |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
276 |
self.assertEqual(u'a => %s\n' % fname, txt) |
1185.85.32
by John Arbash Meinel
Updated bzr renames |
277 |
|
278 |
bzr('renames', retcode=3, encoding='ascii') |
|
279 |
||
1185.85.33
by John Arbash Meinel
Updated bzr remove, still remove --verbose still broken. |
280 |
def test_remove(self): |
281 |
bzr = self.run_bzr_decode |
|
282 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
283 |
fname = self.info['filename'] |
1185.85.33
by John Arbash Meinel
Updated bzr remove, still remove --verbose still broken. |
284 |
txt = bzr('remove', fname, encoding='ascii') |
285 |
||
286 |
def test_remove_verbose(self): |
|
287 |
bzr = self.run_bzr_decode |
|
288 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
289 |
fname = self.info['filename'] |
1185.85.33
by John Arbash Meinel
Updated bzr remove, still remove --verbose still broken. |
290 |
txt = bzr('remove', '--verbose', fname, encoding='ascii') |
291 |
||
1185.85.34
by John Arbash Meinel
Updating 'bzr file-id' exposed that we weren't allowing unicode file ids. Enabling them reveals a lot more bugs. |
292 |
def test_file_id(self): |
293 |
bzr = self.run_bzr_decode |
|
294 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
295 |
fname = self.info['filename'] |
1185.85.34
by John Arbash Meinel
Updating 'bzr file-id' exposed that we weren't allowing unicode file ids. Enabling them reveals a lot more bugs. |
296 |
txt = bzr('file-id', fname) |
297 |
||
1185.85.35
by John Arbash Meinel
Updated file-path |
298 |
# TODO: jam 20060106 We don't support non-ascii file ids yet,
|
299 |
# so there is nothing which would fail in ascii encoding
|
|
300 |
# This *should* be retcode=3
|
|
1185.85.34
by John Arbash Meinel
Updating 'bzr file-id' exposed that we weren't allowing unicode file ids. Enabling them reveals a lot more bugs. |
301 |
txt = bzr('file-id', fname, encoding='ascii') |
302 |
||
1185.85.35
by John Arbash Meinel
Updated file-path |
303 |
def test_file_path(self): |
304 |
bzr = self.run_bzr_decode |
|
305 |
||
306 |
# Create a directory structure
|
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
307 |
fname = self.info['filename'] |
1185.85.72
by John Arbash Meinel
Fix some of the tests. |
308 |
dirname = self.info['directory'] |
1185.85.35
by John Arbash Meinel
Updated file-path |
309 |
bzr('mkdir', 'base') |
1185.85.72
by John Arbash Meinel
Fix some of the tests. |
310 |
bzr('mkdir', 'base/' + dirname) |
311 |
path = '/'.join(['base', dirname, fname]) |
|
1185.85.35
by John Arbash Meinel
Updated file-path |
312 |
bzr('mv', fname, path) |
313 |
bzr('commit', '-m', 'moving things around') |
|
314 |
||
315 |
txt = bzr('file-path', path) |
|
316 |
||
317 |
# TODO: jam 20060106 We don't support non-ascii file ids yet,
|
|
318 |
# so there is nothing which would fail in ascii encoding
|
|
319 |
# This *should* be retcode=3
|
|
320 |
txt = bzr('file-path', path, encoding='ascii') |
|
1185.85.34
by John Arbash Meinel
Updating 'bzr file-id' exposed that we weren't allowing unicode file ids. Enabling them reveals a lot more bugs. |
321 |
|
1185.85.36
by John Arbash Meinel
Working on tests for revision-history, ancestry, and diff |
322 |
def test_revision_history(self): |
323 |
bzr = self.run_bzr_decode |
|
324 |
||
325 |
# TODO: jam 20060106 We don't support non-ascii revision ids yet,
|
|
326 |
# so there is nothing which would fail in ascii encoding
|
|
327 |
txt = bzr('revision-history') |
|
328 |
||
329 |
def test_ancestry(self): |
|
330 |
bzr = self.run_bzr_decode |
|
331 |
||
332 |
# TODO: jam 20060106 We don't support non-ascii revision ids yet,
|
|
333 |
# so there is nothing which would fail in ascii encoding
|
|
334 |
txt = bzr('ancestry') |
|
335 |
||
336 |
def test_diff(self): |
|
337 |
# TODO: jam 20060106 diff is a difficult one to test, because it
|
|
338 |
# shouldn't encode the file contents, but it needs some sort
|
|
339 |
# of encoding for the paths, etc which are displayed.
|
|
1685.1.78
by Wouter van Heyst
more code cleanup |
340 |
open(self.info['filename'], 'ab').write('newline\n') |
341 |
txt = self.run_bzr('diff', retcode=1)[0] |
|
1185.85.41
by John Arbash Meinel
Changing test_non_ascii.py so that it will keep trying even if it can't encode one piece. |
342 |
|
1185.85.49
by John Arbash Meinel
Updated cmd_deleted, including adding --show-ids option. |
343 |
def test_deleted(self): |
344 |
bzr = self.run_bzr_decode |
|
345 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
346 |
fname = self.info['filename'] |
1185.85.49
by John Arbash Meinel
Updated cmd_deleted, including adding --show-ids option. |
347 |
os.remove(fname) |
348 |
bzr('rm', fname) |
|
349 |
||
350 |
txt = bzr('deleted') |
|
351 |
self.assertEqual(fname+'\n', txt) |
|
352 |
||
353 |
txt = bzr('deleted', '--show-ids') |
|
354 |
self.failUnless(txt.startswith(fname)) |
|
355 |
||
1185.85.51
by John Arbash Meinel
Adding tests to make sure deleted and modified fail if cannot encode names. |
356 |
# Deleted should fail if cannot decode
|
357 |
# Because it is giving the exact paths
|
|
358 |
# which might be used by a front end
|
|
359 |
bzr('deleted', encoding='ascii', retcode=3) |
|
360 |
||
1185.85.50
by John Arbash Meinel
Updated cmd_modified |
361 |
def test_modified(self): |
362 |
bzr = self.run_bzr_decode |
|
363 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
364 |
fname = self.info['filename'] |
1185.85.50
by John Arbash Meinel
Updated cmd_modified |
365 |
open(fname, 'ab').write('modified\n') |
366 |
||
367 |
txt = bzr('modified') |
|
368 |
self.assertEqual(fname+'\n', txt) |
|
369 |
||
1185.85.51
by John Arbash Meinel
Adding tests to make sure deleted and modified fail if cannot encode names. |
370 |
bzr('modified', encoding='ascii', retcode=3) |
371 |
||
1185.85.52
by John Arbash Meinel
Updated cmd_added, which obviously had no tests, because it had a bug in it. |
372 |
def test_added(self): |
373 |
bzr = self.run_bzr_decode |
|
374 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
375 |
fname = self.info['filename'] + '2' |
1185.85.52
by John Arbash Meinel
Updated cmd_added, which obviously had no tests, because it had a bug in it. |
376 |
open(fname, 'wb').write('added\n') |
377 |
bzr('add', fname) |
|
378 |
||
379 |
txt = bzr('added') |
|
380 |
self.assertEqual(fname+'\n', txt) |
|
381 |
||
382 |
bzr('added', encoding='ascii', retcode=3) |
|
383 |
||
1185.85.53
by John Arbash Meinel
Updated cmd_root |
384 |
def test_root(self): |
385 |
bzr = self.run_bzr_decode |
|
386 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
387 |
dirname = self.info['directory'] |
1185.85.53
by John Arbash Meinel
Updated cmd_root |
388 |
bzr('root') |
389 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
390 |
bzr('branch', u'.', dirname) |
1185.85.53
by John Arbash Meinel
Updated cmd_root |
391 |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
392 |
os.chdir(dirname) |
1185.85.53
by John Arbash Meinel
Updated cmd_root |
393 |
|
394 |
txt = bzr('root') |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
395 |
self.failUnless(txt.endswith(dirname+'\n')) |
1185.85.53
by John Arbash Meinel
Updated cmd_root |
396 |
|
397 |
txt = bzr('root', encoding='ascii', retcode=3) |
|
398 |
||
1185.85.54
by John Arbash Meinel
Keeping test_non_ascii in the same order as builtins.py |
399 |
def test_log(self): |
400 |
bzr = self.run_bzr_decode |
|
401 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
402 |
fname = self.info['filename'] |
403 |
||
1185.85.54
by John Arbash Meinel
Keeping test_non_ascii in the same order as builtins.py |
404 |
txt = bzr('log') |
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
405 |
self.assertNotEqual(-1, txt.find(self.info['committer'])) |
406 |
self.assertNotEqual(-1, txt.find(self.info['message'])) |
|
1185.85.54
by John Arbash Meinel
Keeping test_non_ascii in the same order as builtins.py |
407 |
|
408 |
txt = bzr('log', '--verbose') |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
409 |
self.assertNotEqual(-1, txt.find(fname)) |
1185.85.54
by John Arbash Meinel
Keeping test_non_ascii in the same order as builtins.py |
410 |
|
411 |
# Make sure log doesn't fail even if we can't write out
|
|
412 |
txt = bzr('log', '--verbose', encoding='ascii') |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
413 |
self.assertEqual(-1, txt.find(fname)) |
414 |
self.assertNotEqual(-1, txt.find(fname.encode('ascii', 'replace'))) |
|
1185.85.54
by John Arbash Meinel
Keeping test_non_ascii in the same order as builtins.py |
415 |
|
1185.85.55
by John Arbash Meinel
Updated cmd_touching_revisions |
416 |
def test_touching_revisions(self): |
417 |
bzr = self.run_bzr_decode |
|
418 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
419 |
fname = self.info['filename'] |
1185.85.55
by John Arbash Meinel
Updated cmd_touching_revisions |
420 |
txt = bzr('touching-revisions', fname) |
421 |
self.assertEqual(u' 3 added %s\n' % (fname,), txt) |
|
422 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
423 |
fname2 = self.info['filename'] + '2' |
424 |
bzr('mv', fname, fname2) |
|
425 |
bzr('commit', '-m', u'Renamed %s => %s' % (fname, fname2)) |
|
1185.85.55
by John Arbash Meinel
Updated cmd_touching_revisions |
426 |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
427 |
txt = bzr('touching-revisions', fname2) |
1185.85.55
by John Arbash Meinel
Updated cmd_touching_revisions |
428 |
expected_txt = (u' 3 added %s\n' |
429 |
u' 4 renamed %s => %s\n' |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
430 |
% (fname, fname, fname2)) |
1185.85.55
by John Arbash Meinel
Updated cmd_touching_revisions |
431 |
self.assertEqual(expected_txt, txt) |
432 |
||
1685.1.78
by Wouter van Heyst
more code cleanup |
433 |
bzr('touching-revisions', fname2, encoding='ascii', retcode=3) |
1185.85.55
by John Arbash Meinel
Updated cmd_touching_revisions |
434 |
|
1185.85.56
by John Arbash Meinel
Keeping test_non_ascii in the same order as builtins.py |
435 |
def test_ls(self): |
436 |
bzr = self.run_bzr_decode |
|
437 |
||
438 |
txt = bzr('ls') |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
439 |
self.assertEqual(['a', 'b', self.info['filename']], |
1185.85.56
by John Arbash Meinel
Keeping test_non_ascii in the same order as builtins.py |
440 |
txt.splitlines()) |
441 |
txt = bzr('ls', '--null') |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
442 |
self.assertEqual(['a', 'b', self.info['filename'], ''], |
1185.85.56
by John Arbash Meinel
Keeping test_non_ascii in the same order as builtins.py |
443 |
txt.split('\0')) |
444 |
||
445 |
txt = bzr('ls', encoding='ascii', retcode=3) |
|
446 |
txt = bzr('ls', '--null', encoding='ascii', retcode=3) |
|
447 |
||
1185.85.57
by John Arbash Meinel
Updated cmd_unknowns |
448 |
def test_unknowns(self): |
449 |
bzr = self.run_bzr_decode |
|
450 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
451 |
fname = self.info['filename'] + '2' |
1185.85.57
by John Arbash Meinel
Updated cmd_unknowns |
452 |
open(fname, 'wb').write('unknown\n') |
453 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
454 |
# TODO: jam 20060112 bzr unknowns is the only one which
|
455 |
# quotes paths do we really want it to?
|
|
1185.85.57
by John Arbash Meinel
Updated cmd_unknowns |
456 |
txt = bzr('unknowns') |
457 |
self.assertEqual(u'"%s"\n' % (fname,), txt) |
|
458 |
||
459 |
bzr('unknowns', encoding='ascii', retcode=3) |
|
460 |
||
1185.85.58
by John Arbash Meinel
Working on bzr ignore, found that WorkingTree.is_ignored doesn't handle unicode names. |
461 |
def test_ignore(self): |
462 |
bzr = self.run_bzr_decode |
|
463 |
||
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
464 |
fname2 = self.info['filename'] + '2.txt' |
1185.85.58
by John Arbash Meinel
Working on bzr ignore, found that WorkingTree.is_ignored doesn't handle unicode names. |
465 |
open(fname2, 'wb').write('ignored\n') |
466 |
||
467 |
txt = bzr('unknowns') |
|
468 |
self.assertEqual(u'"%s"\n' % (fname2,), txt) |
|
469 |
||
470 |
bzr('ignore', './' + fname2) |
|
471 |
txt = bzr('unknowns') |
|
1685.1.2
by John Arbash Meinel
Re-enabling the non_ascii tests after fixing trace.py, bzr ignore also does the right thing now |
472 |
self.assertEqual(u'', txt) |
1185.85.58
by John Arbash Meinel
Working on bzr ignore, found that WorkingTree.is_ignored doesn't handle unicode names. |
473 |
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
474 |
fname3 = self.info['filename'] + '3.txt' |
1185.85.59
by John Arbash Meinel
Adding extra tests for future corrections to WorkingTree.is_ignored() |
475 |
open(fname3, 'wb').write('unknown 3\n') |
1185.85.58
by John Arbash Meinel
Working on bzr ignore, found that WorkingTree.is_ignored doesn't handle unicode names. |
476 |
txt = bzr('unknowns') |
1685.1.2
by John Arbash Meinel
Re-enabling the non_ascii tests after fixing trace.py, bzr ignore also does the right thing now |
477 |
self.assertEqual(u'"%s"\n' % (fname3,), txt) |
1185.85.58
by John Arbash Meinel
Working on bzr ignore, found that WorkingTree.is_ignored doesn't handle unicode names. |
478 |
|
479 |
# Ignore should not care what the encoding is
|
|
480 |
# (right now it doesn't print anything)
|
|
481 |
bzr('ignore', fname3, encoding='ascii') |
|
482 |
txt = bzr('unknowns') |
|
1685.1.2
by John Arbash Meinel
Re-enabling the non_ascii tests after fixing trace.py, bzr ignore also does the right thing now |
483 |
self.assertEqual('', txt) |
1185.85.59
by John Arbash Meinel
Adding extra tests for future corrections to WorkingTree.is_ignored() |
484 |
|
485 |
# Now try a wildcard match
|
|
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
486 |
fname4 = self.info['filename'] + '4.txt' |
487 |
open(fname4, 'wb').write('unknown 4\n') |
|
1185.85.59
by John Arbash Meinel
Adding extra tests for future corrections to WorkingTree.is_ignored() |
488 |
bzr('ignore', '*.txt') |
489 |
txt = bzr('unknowns') |
|
1185.85.58
by John Arbash Meinel
Working on bzr ignore, found that WorkingTree.is_ignored doesn't handle unicode names. |
490 |
self.assertEqual('', txt) |
1185.85.53
by John Arbash Meinel
Updated cmd_root |
491 |
|
1185.85.59
by John Arbash Meinel
Adding extra tests for future corrections to WorkingTree.is_ignored() |
492 |
os.remove('.bzrignore') |
1185.85.70
by John Arbash Meinel
Hooked up EncodingAdapter, and updated test_non_ascii. |
493 |
bzr('ignore', self.info['filename'] + '*') |
1185.85.59
by John Arbash Meinel
Adding extra tests for future corrections to WorkingTree.is_ignored() |
494 |
txt = bzr('unknowns') |
1685.1.2
by John Arbash Meinel
Re-enabling the non_ascii tests after fixing trace.py, bzr ignore also does the right thing now |
495 |
self.assertEqual('', txt) |
1185.85.59
by John Arbash Meinel
Adding extra tests for future corrections to WorkingTree.is_ignored() |
496 |
|
497 |