@@ -980,16 +980,21 @@ def test_walk_bad_dir(self):
980980 errors = []
981981 walk_it = self .walk (self .walk_path , onerror = errors .append )
982982 root , dirs , files = next (walk_it )
983- self .assertFalse (errors )
984- dir1 = dirs [0 ]
985- dir1new = dir1 + '.new'
986- os .rename (os .path .join (root , dir1 ), os .path .join (root , dir1new ))
987- roots = [r for r , d , f in walk_it ]
988- self .assertTrue (errors )
989- self .assertNotIn (os .path .join (root , dir1 ), roots )
990- self .assertNotIn (os .path .join (root , dir1new ), roots )
991- for dir2 in dirs [1 :]:
992- self .assertIn (os .path .join (root , dir2 ), roots )
983+ self .assertEqual (errors , [])
984+ dir1 = 'SUB1'
985+ path1 = os .path .join (root , dir1 )
986+ path1new = os .path .join (root , dir1 + '.new' )
987+ os .rename (path1 , path1new )
988+ try :
989+ roots = [r for r , d , f in walk_it ]
990+ self .assertTrue (errors )
991+ self .assertNotIn (path1 , roots )
992+ self .assertNotIn (path1new , roots )
993+ for dir2 in dirs :
994+ if dir2 != dir1 :
995+ self .assertIn (os .path .join (root , dir2 ), roots )
996+ finally :
997+ os .rename (path1new , path1 )
993998
994999
9951000@unittest .skipUnless (hasattr (os , 'fwalk' ), "Test needs os.fwalk()" )
0 commit comments