cpython: 655510dd46fd (original) (raw)
Mercurial > cpython
changeset 104764:655510dd46fd 3.5
Issue #28353: Make test_os.WalkTests.test_walk_bad_dir stable. [#28353]
Serhiy Storchaka storchaka@gmail.com | |
---|---|
date | Fri, 28 Oct 2016 09:17:38 +0300 |
parents | a1aef5f84142 |
children | df28e536f19d 695cea018ba9 |
files | Lib/test/test_os.py |
diffstat | 1 files changed, 15 insertions(+), 10 deletions(-)[+] [-] Lib/test/test_os.py 25 |
line wrap: on
line diff
--- a/Lib/test/test_os.py +++ b/Lib/test/test_os.py @@ -980,16 +980,21 @@ class WalkTests(unittest.TestCase): errors = [] walk_it = self.walk(self.walk_path, onerror=errors.append) root, dirs, files = next(walk_it)
self.assertFalse(errors)[](#l1.7)
dir1 = dirs[0][](#l1.8)
dir1new = dir1 + '.new'[](#l1.9)
os.rename(os.path.join(root, dir1), os.path.join(root, dir1new))[](#l1.10)
roots = [r for r, d, f in walk_it][](#l1.11)
self.assertTrue(errors)[](#l1.12)
self.assertNotIn(os.path.join(root, dir1), roots)[](#l1.13)
self.assertNotIn(os.path.join(root, dir1new), roots)[](#l1.14)
for dir2 in dirs[1:]:[](#l1.15)
self.assertIn(os.path.join(root, dir2), roots)[](#l1.16)
self.assertEqual(errors, [])[](#l1.17)
dir1 = 'SUB1'[](#l1.18)
path1 = os.path.join(root, dir1)[](#l1.19)
path1new = os.path.join(root, dir1 + '.new')[](#l1.20)
os.rename(path1, path1new)[](#l1.21)
try:[](#l1.22)
roots = [r for r, d, f in walk_it][](#l1.23)
self.assertTrue(errors)[](#l1.24)
self.assertNotIn(path1, roots)[](#l1.25)
self.assertNotIn(path1new, roots)[](#l1.26)
for dir2 in dirs:[](#l1.27)
if dir2 != dir1:[](#l1.28)
self.assertIn(os.path.join(root, dir2), roots)[](#l1.29)
finally:[](#l1.30)
os.rename(path1new, path1)[](#l1.31)
@unittest.skipUnless(hasattr(os, 'fwalk'), "Test needs os.fwalk()")