~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: John Arbash Meinel
  • Date: 2006-08-07 17:51:49 UTC
  • mto: (1908.2.1 commit-perf)
  • mto: This revision was merged to the branch mainline in revision 1923.
  • Revision ID: john@arbash-meinel.com-20060807175149-cf3081f5c81e3f89
Updated the copy_tree function to allow overriding functionality.

Show diffs side-by-side

added added

removed removed

Lines of Context:
435
435
        self.assertEqual(['a', 'b'], os.listdir('target'))
436
436
        self.assertEqual(['c'], os.listdir('target/b'))
437
437
 
 
438
    def test_copy_tree_symlinks(self):
 
439
        if not osutils.has_symlinks():
 
440
            return
 
441
        self.build_tree(['source/'])
 
442
        os.symlink('a/generic/path', 'source/lnk')
 
443
        osutils.copy_tree('source', 'target')
 
444
        self.assertEqual(['lnk'], os.listdir('target'))
 
445
        self.assertEqual('a/generic/path', os.readlink('target/lnk'))
 
446
 
 
447
    def test_copy_tree_handlers(self):
 
448
        processed_files = []
 
449
        processed_links = []
 
450
        def file_handler(from_path, to_path):
 
451
            processed_files.append(('f', from_path, to_path))
 
452
        def dir_handler(from_path, to_path):
 
453
            processed_files.append(('d', from_path, to_path))
 
454
        def link_handler(from_path, to_path):
 
455
            processed_links.append((from_path, to_path))
 
456
        handlers = {'file':file_handler,
 
457
                    'directory':dir_handler,
 
458
                    'symlink':link_handler,
 
459
                   }
 
460
 
 
461
        self.build_tree(['source/', 'source/a', 'source/b/', 'source/b/c'])
 
462
        if osutils.has_symlinks():
 
463
            os.symlink('a/generic/path', 'source/lnk')
 
464
        osutils.copy_tree('source', 'target', handlers=handlers)
 
465
 
 
466
        self.assertEqual([('d', 'source', 'target'),
 
467
                          ('f', 'source/a', 'target/a'),
 
468
                          ('d', 'source/b', 'target/b'),
 
469
                          ('f', 'source/b/c', 'target/b/c'),
 
470
                         ], processed_files)
 
471
        self.failIfExists('target')
 
472
        if osutils.has_symlinks():
 
473
            self.assertEqual([('source/lnk', 'target/lnk')], processed_links)
 
474
 
438
475
 
439
476
class TestTerminalEncoding(TestCase):
440
477
    """Test the auto-detection of proper terminal encoding."""