@@ -989,16 +989,21 @@ def test_walk_bad_dir(self):
989989 errors = []
990990 walk_it = self .walk (self .walk_path , onerror = errors .append )
991991 root , dirs , files = next (walk_it )
992- self .assertFalse (errors )
993- dir1 = dirs [0 ]
994- dir1new = dir1 + '.new'
995- os .rename (os .path .join (root , dir1 ), os .path .join (root , dir1new ))
996- roots = [r for r , d , f in walk_it ]
997- self .assertTrue (errors )
998- self .assertNotIn (os .path .join (root , dir1 ), roots )
999- self .assertNotIn (os .path .join (root , dir1new ), roots )
1000- for dir2 in dirs [1 :]:
1001- self .assertIn (os .path .join (root , dir2 ), roots )
992+ self .assertEqual (errors , [])
993+ dir1 = 'SUB1'
994+ path1 = os .path .join (root , dir1 )
995+ path1new = os .path .join (root , dir1 + '.new' )
996+ os .rename (path1 , path1new )
997+ try :
998+ roots = [r for r , d , f in walk_it ]
999+ self .assertTrue (errors )
1000+ self .assertNotIn (path1 , roots )
1001+ self .assertNotIn (path1new , roots )
1002+ for dir2 in dirs :
1003+ if dir2 != dir1 :
1004+ self .assertIn (os .path .join (root , dir2 ), roots )
1005+ finally :
1006+ os .rename (path1new , path1 )
10021007
10031008
10041009@unittest .skipUnless (hasattr (os , 'fwalk' ), "Test needs os.fwalk()" )
0 commit comments