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

Method test_walk_bad_dir

Lib/test/test_os/test_os.py:1833–1852  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1831 self.assertRaises(StopIteration, next, walk_it)
1832
1833 def test_walk_bad_dir(self):
1834 # Walk top-down.
1835 errors = []
1836 walk_it = self.walk(self.walk_path, onerror=errors.append)
1837 root, dirs, files = next(walk_it)
1838 self.assertEqual(errors, [])
1839 dir1 = 'SUB1'
1840 path1 = os.path.join(root, dir1)
1841 path1new = os.path.join(root, dir1 + '.new')
1842 os.rename(path1, path1new)
1843 try:
1844 roots = [r for r, d, f in walk_it]
1845 self.assertTrue(errors)
1846 self.assertNotIn(path1, roots)
1847 self.assertNotIn(path1new, roots)
1848 for dir2 in dirs:
1849 if dir2 != dir1:
1850 self.assertIn(os.path.join(root, dir2), roots)
1851 finally:
1852 os.rename(path1new, path1)
1853
1854 def test_walk_bad_dir2(self):
1855 walk_it = self.walk('nonexisting')

Callers

nothing calls this directly

Calls 7

walkMethod · 0.95
assertTrueMethod · 0.80
assertNotInMethod · 0.80
assertInMethod · 0.80
assertEqualMethod · 0.45
joinMethod · 0.45
renameMethod · 0.45

Tested by

no test coverage detected