MCPcopy Index your code
hub / github.com/python/cpython / test_walk_prune

Method test_walk_prune

Lib/test/test_os/test_os.py:1771–1788  ·  view source on GitHub ↗
(self, walk_path=None)

Source from the content-addressed store, hash-verified

1769 self.assertEqual(all[3 - 2 * flipped], self.sub2_tree)
1770
1771 def test_walk_prune(self, walk_path=None):
1772 if walk_path is None:
1773 walk_path = self.walk_path
1774 # Prune the search.
1775 all = []
1776 for root, dirs, files in self.walk(walk_path):
1777 all.append((root, dirs, files))
1778 # Don't descend into SUB1.
1779 if 'SUB1' in dirs:
1780 # Note that this also mutates the dirs we appended to all!
1781 dirs.remove('SUB1')
1782
1783 self.assertEqual(len(all), 2)
1784 self.assertEqual(all[0], (self.walk_path, ["SUB2"], ["tmp1"]))
1785
1786 all[1][-1].sort()
1787 all[1][1].sort()
1788 self.assertEqual(all[1], self.sub2_tree)
1789
1790 def test_file_like_path(self):
1791 self.test_walk_prune(FakePath(self.walk_path))

Callers 1

test_file_like_pathMethod · 0.95

Calls 5

walkMethod · 0.95
appendMethod · 0.45
removeMethod · 0.45
assertEqualMethod · 0.45
sortMethod · 0.45

Tested by

no test coverage detected