/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/test_osutils.py

Merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
198
198
    def test_getcwd(self):
199
199
        # Make sure getcwd can handle unicode filenames
200
200
        try:
201
 
            os.mkdir(u'B\xe5gfors')
 
201
            os.mkdir(u'mu-\xb5')
202
202
        except UnicodeError:
203
203
            raise TestSkipped("Unable to create Unicode filename")
204
204
 
205
 
        os.chdir(u'B\xe5gfors')
 
205
        os.chdir(u'mu-\xb5')
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')
211
211
 
212
212
    def test_mkdtemp(self):
213
213
        tmpdir = osutils._win32_mkdtemp(dir='.')
257
257
            self.assertEqual(errno.ENOENT, e.errno)
258
258
 
259
259
 
 
260
class TestMacFuncsDirs(TestCaseInTempDir):
 
261
    """Test mac special functions that require directories."""
 
262
 
 
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
 
266
        try:
 
267
            os.mkdir(u'B\xe5gfors')
 
268
        except UnicodeError:
 
269
            raise TestSkipped("Unable to create Unicode filename")
 
270
 
 
271
        os.chdir(u'B\xe5gfors')
 
272
        self.assertEndsWith(osutils._mac_getcwd(), u'B\xe5gfors')
 
273
 
 
274
    def test_getcwd_nonnorm(self):
 
275
        # Test that _mac_getcwd() will normalize this path
 
276
        try:
 
277
            os.mkdir(u'Ba\u030agfors')
 
278
        except UnicodeError:
 
279
            raise TestSkipped("Unable to create Unicode filename")
 
280
 
 
281
        os.chdir(u'Ba\u030agfors')
 
282
        self.assertEndsWith(osutils._mac_getcwd(), u'B\xe5gfors')
 
283
 
260
284
class TestSplitLines(TestCase):
261
285
 
262
286
    def test_split_unicode(self):
283
307
            ]
284
308
        self.build_tree(tree)
285
309
        expected_dirblocks = [
286
 
                [
287
 
                    ('0file', '0file', 'file'),
288
 
                    ('1dir', '1dir', 'directory'),
289
 
                    ('2file', '2file', 'file'),
290
 
                ],
291
 
                [
292
 
                    ('1dir/0file', '0file', 'file'),
293
 
                    ('1dir/1dir', '1dir', 'directory'),
294
 
                ],
295
 
                [
296
 
                ],
 
310
                (('', '.'),
 
311
                 [('0file', '0file', 'file'),
 
312
                  ('1dir', '1dir', 'directory'),
 
313
                  ('2file', '2file', 'file'),
 
314
                 ]
 
315
                ),
 
316
                (('1dir', './1dir'),
 
317
                 [('1dir/0file', '0file', 'file'),
 
318
                  ('1dir/1dir', '1dir', 'directory'),
 
319
                 ]
 
320
                ),
 
321
                (('1dir/1dir', './1dir/1dir'),
 
322
                 [
 
323
                 ]
 
324
                ),
297
325
            ]
298
326
        result = []
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
304
332
                del dirblock[0]
305
 
            result.append(dirblock)
 
333
            result.append((dirdetail, dirblock))
306
334
 
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.
311
339
        result = []
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])
316
344
 
317
345
    def assertPathCompare(self, path_less, path_greater):
318
346
        """check that path_less and path_greater compare correctly."""