~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/tests/test_osutils.py

  • Committer: Vincent Ladeuil
  • Date: 2009-04-10 15:54:36 UTC
  • mto: (4331.1.1 integration)
  • mto: This revision was merged to the branch mainline in revision 4332.
  • Revision ID: v.ladeuil+lp@free.fr-20090410155436-930xgee26ccft90d
Add a test for symlinks name handling.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1685
1685
            ]
1686
1686
        return tree, expected_dirblocks
1687
1687
 
1688
 
    def test_walk_unicode_tree(self):
1689
 
        tree, expected_dirblocks = self._get_unicode_tree()
1690
 
        self.build_tree(tree)
1691
 
        result = list(osutils._walkdirs_utf8('.'))
1692
 
        # Filter out stat and convert native abspaths to unicode
1693
 
        actual_dirblocks = []
1694
 
        for dirinfo, block in result:
 
1688
    def _filter_out(self, raw_dirblocks):
 
1689
        """Filter out a walkdirs_utf8 result.
 
1690
 
 
1691
        stat field is removed, all native paths are converted to unicode
 
1692
        """
 
1693
        filtered_dirblocks = []
 
1694
        for dirinfo, block in raw_dirblocks:
1695
1695
            dirinfo = (dirinfo[0], self._native_to_unicode(dirinfo[1]))
1696
1696
            details = []
1697
1697
            for line in block:
1698
1698
                details.append(line[0:3] + (self._native_to_unicode(line[4]), ))
1699
 
            actual_dirblocks.append((dirinfo, details))
1700
 
        self.assertEqual(expected_dirblocks, actual_dirblocks)
1701
 
 
 
1699
            filtered_dirblocks.append((dirinfo, details))
 
1700
        return filtered_dirblocks
 
1701
 
 
1702
    def test_walk_unicode_tree(self):
 
1703
        tree, expected_dirblocks = self._get_unicode_tree()
 
1704
        self.build_tree(tree)
 
1705
        result = list(osutils._walkdirs_utf8('.'))
 
1706
        self.assertEqual(expected_dirblocks, self._filter_out(result))
 
1707
 
 
1708
    def test_symlink(self):
 
1709
        self.requireFeature(tests.SymlinkFeature)
 
1710
        target = u'target\n{Euro Sign}'
 
1711
        link_name = u'l\n{Euro Sign}nk'
 
1712
        os.symlink(target, link_name)
 
1713
        target_utf8 = target.encode('UTF-8')
 
1714
        link_name_utf8 = link_name.encode('UTF-8')
 
1715
        expected_dirblocks = [
 
1716
                (('', '.'),
 
1717
                 [(link_name_utf8, link_name_utf8,
 
1718
                   'symlink', './' + link_name),],
 
1719
                 )]
 
1720
        result = list(osutils._walkdirs_utf8('.'))
 
1721
        self.assertEqual(expected_dirblocks, self._filter_out(result))