[Python-checkins] cpython (3.6): Issue #28353: Try to fix tests.

serhiy.storchaka python-checkins at python.org
Tue Oct 25 12:03:41 EDT 2016


https://hg.python.org/cpython/rev/ec12e16ea6a1
changeset:   104720:ec12e16ea6a1
branch:      3.6
parent:      104718:bb23770f82f1
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Tue Oct 25 19:01:41 2016 +0300
summary:
  Issue #28353: Try to fix tests.

files:
  Lib/test/test_os.py |  15 +++++++++++++--
  1 files changed, 13 insertions(+), 2 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
@@ -892,14 +892,22 @@
             os.symlink('broken', broken_link_path, True)
             os.symlink(join('tmp3', 'broken'), broken_link2_path, True)
             os.symlink(join('SUB21', 'tmp5'), broken_link3_path, True)
-            self.sub2_tree = (sub2_path, ["link", "SUB21"],
+            self.sub2_tree = (sub2_path, ["SUB21", "link"],
                               ["broken_link", "broken_link2", "broken_link3",
                                "tmp3"])
         else:
             self.sub2_tree = (sub2_path, [], ["tmp3"])
 
         os.chmod(sub21_path, 0)
-        self.addCleanup(os.chmod, sub21_path, stat.S_IRWXU)
+        try:
+            os.listdir(sub21_path)
+        except PermissionError:
+            self.addCleanup(os.chmod, sub21_path, stat.S_IRWXU)
+        else:
+            os.chmod(sub21_path, stat.S_IRWXU)
+            os.unlink(tmp5_path)
+            os.rmdir(sub21_path)
+            del self.sub2_tree[1][:1]
 
     def test_walk_topdown(self):
         # Walk top-down.
@@ -912,6 +920,7 @@
         flipped = all[0][1][0] != "SUB1"
         all[0][1].sort()
         all[3 - 2 * flipped][-1].sort()
+        all[3 - 2 * flipped][1].sort()
         self.assertEqual(all[0], (self.walk_path, ["SUB1", "SUB2"], ["tmp1"]))
         self.assertEqual(all[1 + flipped], (self.sub1_path, ["SUB11"], ["tmp2"]))
         self.assertEqual(all[2 + flipped], (self.sub11_path, [], []))
@@ -934,6 +943,7 @@
                          (str(walk_path), ["SUB2"], ["tmp1"]))
 
         all[1][-1].sort()
+        all[1][1].sort()
         self.assertEqual(all[1], self.sub2_tree)
 
     def test_file_like_path(self):
@@ -950,6 +960,7 @@
         flipped = all[3][1][0] != "SUB1"
         all[3][1].sort()
         all[2 - 2 * flipped][-1].sort()
+        all[2 - 2 * flipped][1].sort()
         self.assertEqual(all[3],
                          (self.walk_path, ["SUB1", "SUB2"], ["tmp1"]))
         self.assertEqual(all[flipped],

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list