@@ -853,38 +853,54 @@ def setUp(self):
853853 # SUB11/ no kids
854854 # SUB2/ a file kid and a dirsymlink kid
855855 # tmp3
856+ # SUB21/ not readable
857+ # tmp5
856858 # link/ a symlink to TESTFN.2
857859 # broken_link
860+ # broken_link2
861+ # broken_link3
858862 # TEST2/
859863 # tmp4 a lone file
860864 self .walk_path = join (support .TESTFN , "TEST1" )
861865 self .sub1_path = join (self .walk_path , "SUB1" )
862866 self .sub11_path = join (self .sub1_path , "SUB11" )
863867 sub2_path = join (self .walk_path , "SUB2" )
868+ sub21_path = join (sub2_path , "SUB21" )
864869 tmp1_path = join (self .walk_path , "tmp1" )
865870 tmp2_path = join (self .sub1_path , "tmp2" )
866871 tmp3_path = join (sub2_path , "tmp3" )
872+ tmp5_path = join (sub21_path , "tmp3" )
867873 self .link_path = join (sub2_path , "link" )
868874 t2_path = join (support .TESTFN , "TEST2" )
869875 tmp4_path = join (support .TESTFN , "TEST2" , "tmp4" )
870876 broken_link_path = join (sub2_path , "broken_link" )
877+ broken_link2_path = join (sub2_path , "broken_link2" )
878+ broken_link3_path = join (sub2_path , "broken_link3" )
871879
872880 # Create stuff.
873881 os .makedirs (self .sub11_path )
874882 os .makedirs (sub2_path )
883+ os .makedirs (sub21_path )
875884 os .makedirs (t2_path )
876885
877- for path in tmp1_path , tmp2_path , tmp3_path , tmp4_path :
886+ for path in tmp1_path , tmp2_path , tmp3_path , tmp4_path , tmp5_path :
878887 with open (path , "x" ) as f :
879888 f .write ("I'm " + path + " and proud of it. Blame test_os.\n " )
880889
881890 if support .can_symlink ():
882891 os .symlink (os .path .abspath (t2_path ), self .link_path )
883892 os .symlink ('broken' , broken_link_path , True )
884- self .sub2_tree = (sub2_path , ["link" ], ["broken_link" , "tmp3" ])
893+ os .symlink (join ('tmp3' , 'broken' ), broken_link2_path , True )
894+ os .symlink (join ('SUB21' , 'tmp5' ), broken_link3_path , True )
895+ self .sub2_tree = (sub2_path , ["link" , "SUB21" ],
896+ ["broken_link" , "broken_link2" , "broken_link3" ,
897+ "tmp3" ])
885898 else :
886899 self .sub2_tree = (sub2_path , [], ["tmp3" ])
887900
901+ os .chmod (sub21_path , 0 )
902+ self .addCleanup (os .chmod , sub21_path , stat .S_IRWXU )
903+
888904 def test_walk_topdown (self ):
889905 # Walk top-down.
890906 all = list (self .walk (self .walk_path ))
0 commit comments