198
198
def test_getcwd(self):
199
199
# Make sure getcwd can handle unicode filenames
201
os.mkdir(u'B\xe5gfors')
202
202
except UnicodeError:
203
203
raise TestSkipped("Unable to create Unicode filename")
205
os.chdir(u'B\xe5gfors')
206
206
# TODO: jam 20060427 This will probably fail on Mac OSX because
207
207
# it will change the normalization of B\xe5gfors
208
208
# Consider using a different unicode character, or make
209
209
# osutils.getcwd() renormalize the path.
210
self.assertTrue(osutils._win32_getcwd().endswith(u'/B\xe5gfors'))
210
self.assertEndsWith(osutils._win32_getcwd(), u'mu-\xb5')
212
212
def test_mkdtemp(self):
213
213
tmpdir = osutils._win32_mkdtemp(dir='.')
257
257
self.assertEqual(errno.ENOENT, e.errno)
260
class TestMacFuncsDirs(TestCaseInTempDir):
261
"""Test mac special functions that require directories."""
263
def test_getcwd(self):
264
# On Mac, this will actually create Ba\u030agfors
265
# but chdir will still work, because it accepts both paths
267
os.mkdir(u'B\xe5gfors')
269
raise TestSkipped("Unable to create Unicode filename")
271
os.chdir(u'B\xe5gfors')
272
self.assertEndsWith(osutils._mac_getcwd(), u'B\xe5gfors')
274
def test_getcwd_nonnorm(self):
275
# Test that _mac_getcwd() will normalize this path
277
os.mkdir(u'Ba\u030agfors')
279
raise TestSkipped("Unable to create Unicode filename")
281
os.chdir(u'Ba\u030agfors')
282
self.assertEndsWith(osutils._mac_getcwd(), u'B\xe5gfors')
260
284
class TestSplitLines(TestCase):
262
286
def test_split_unicode(self):
284
308
self.build_tree(tree)
285
309
expected_dirblocks = [
287
('0file', '0file', 'file'),
288
('1dir', '1dir', 'directory'),
289
('2file', '2file', 'file'),
292
('1dir/0file', '0file', 'file'),
293
('1dir/1dir', '1dir', 'directory'),
311
[('0file', '0file', 'file'),
312
('1dir', '1dir', 'directory'),
313
('2file', '2file', 'file'),
317
[('1dir/0file', '0file', 'file'),
318
('1dir/1dir', '1dir', 'directory'),
321
(('1dir/1dir', './1dir/1dir'),
299
327
found_bzrdir = False
300
for dirblock in osutils.walkdirs('.'):
328
for dirdetail, dirblock in osutils.walkdirs('.'):
301
329
if len(dirblock) and dirblock[0][1] == '.bzr':
302
330
# this tests the filtering of selected paths
303
331
found_bzrdir = True
305
result.append(dirblock)
333
result.append((dirdetail, dirblock))
307
335
self.assertTrue(found_bzrdir)
308
336
self.assertEqual(expected_dirblocks,
309
[[line[0:3] for line in block] for block in result])
337
[(dirinfo, [line[0:3] for line in block]) for dirinfo, block in result])
310
338
# you can search a subdir only, with a supplied prefix.
312
for dirblock in osutils.walkdirs('1dir', '1dir'):
340
for dirblock in osutils.walkdirs('./1dir', '1dir'):
313
341
result.append(dirblock)
314
342
self.assertEqual(expected_dirblocks[1:],
315
[[line[0:3] for line in block] for block in result])
343
[(dirinfo, [line[0:3] for line in block]) for dirinfo, block in result])
317
345
def assertPathCompare(self, path_less, path_greater):
318
346
"""check that path_less and path_greater compare correctly."""