[Python-checkins] cpython (merge 3.6 -> default): Issue #28353: Make test_os.WalkTests.test_walk_bad_dir stable.
serhiy.storchaka
python-checkins at python.org
Fri Oct 28 02:19:44 EDT 2016
https://hg.python.org/cpython/rev/aa891d13e1cf
changeset: 104766:aa891d13e1cf
parent: 104763:72e64fc8746b
parent: 104765:df28e536f19d
user: Serhiy Storchaka <storchaka at gmail.com>
date: Fri Oct 28 09:19:19 2016 +0300
summary:
Issue #28353: Make test_os.WalkTests.test_walk_bad_dir stable.
files:
Lib/test/test_os.py | 25 +++++++++++++++----------
1 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -989,16 +989,21 @@
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()")
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list