1686
1686
return tree, expected_dirblocks
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.
1691
stat field is removed, all native paths are converted to unicode
1693
filtered_dirblocks = []
1694
for dirinfo, block in raw_dirblocks:
1695
1695
dirinfo = (dirinfo[0], self._native_to_unicode(dirinfo[1]))
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)
1699
filtered_dirblocks.append((dirinfo, details))
1700
return filtered_dirblocks
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))
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 = [
1717
[(link_name_utf8, link_name_utf8,
1718
'symlink', './' + link_name),],
1720
result = list(osutils._walkdirs_utf8('.'))
1721
self.assertEqual(expected_dirblocks, self._filter_out(result))