summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_os.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-10-28 06:18:30 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2016-10-28 06:18:30 (GMT)
commitb6bd81dee9a7a3fea03c92e27eb232fee9ce8077 (patch)
tree139dcca2cc826e857e0599f4296f2969508aab3c /Lib/test/test_os.py
parentc6dd415252f255b583fcdae5d51a28e027284b06 (diff)
parent7865dfff2e3408948bada0034ec1d3d29f655cc1 (diff)
downloadcpython-b6bd81dee9a7a3fea03c92e27eb232fee9ce8077.zip
cpython-b6bd81dee9a7a3fea03c92e27eb232fee9ce8077.tar.gz
cpython-b6bd81dee9a7a3fea03c92e27eb232fee9ce8077.tar.bz2
Issue #28353: Make test_os.WalkTests.test_walk_bad_dir stable.
Diffstat (limited to 'Lib/test/test_os.py')
-rw-r--r--Lib/test/test_os.py25
1 files changed, 15 insertions, 10 deletions
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index 9bfb244..638244f 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -989,16 +989,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)
- dir1 = dirs[0]
- dir1new = dir1 + '.new'
- os.rename(os.path.join(root, dir1), os.path.join(root, dir1new))
- roots = [r for r, d, f in walk_it]
- self.assertTrue(errors)
- self.assertNotIn(os.path.join(root, dir1), roots)
- self.assertNotIn(os.path.join(root, dir1new), roots)
- for dir2 in dirs[1:]:
- self.assertIn(os.path.join(root, dir2), roots)
+ self.assertEqual(errors, [])
+ dir1 = 'SUB1'
+ path1 = os.path.join(root, dir1)
+ path1new = os.path.join(root, dir1 + '.new')
+ os.rename(path1, path1new)
+ try:
+ roots = [r for r, d, f in walk_it]
+ self.assertTrue(errors)
+ self.assertNotIn(path1, roots)
+ self.assertNotIn(path1new, roots)
+ for dir2 in dirs:
+ if dir2 != dir1:
+ self.assertIn(os.path.join(root, dir2), roots)
+ finally:
+ os.rename(path1new, path1)
@unittest.skipUnless(hasattr(os, 'fwalk'), "Test needs os.fwalk()")