@@ -1580,52 +1580,35 @@ class DummyPathWalkTest(unittest.TestCase):
1580
1580
can_symlink = False
1581
1581
1582
1582
def setUp (self ):
1583
- # Build:
1584
- # TESTFN/
1585
- # TEST1/ a file kid and two directory kids
1586
- # tmp1
1587
- # SUB1/ a file kid and a directory kid
1588
- # tmp2
1589
- # SUB11/ no kids
1590
- # SUB2/ a file kid and a dirsymlink kid
1591
- # tmp3
1592
- # link/ a symlink to TEST2
1593
- # broken_link
1594
- # broken_link2
1595
- # TEST2/
1596
- # tmp4 a lone file
1597
1583
self .walk_path = self .cls (self .base , "TEST1" )
1598
1584
self .sub1_path = self .walk_path / "SUB1"
1599
1585
self .sub11_path = self .sub1_path / "SUB11"
1600
1586
self .sub2_path = self .walk_path / "SUB2"
1601
- tmp1_path = self .walk_path / "tmp1"
1602
- tmp2_path = self .sub1_path / "tmp2"
1603
- tmp3_path = self .sub2_path / "tmp3"
1604
1587
self .link_path = self .sub2_path / "link"
1605
- t2_path = self .cls (self .base , "TEST2" )
1606
- tmp4_path = self .cls (self .base , "TEST2" , "tmp4" )
1607
- broken_link_path = self .sub2_path / "broken_link"
1608
- broken_link2_path = self .sub2_path / "broken_link2"
1609
-
1610
- self .sub11_path .mkdir (parents = True )
1611
- self .sub2_path .mkdir (parents = True )
1612
- t2_path .mkdir (parents = True )
1613
-
1614
- for path in tmp1_path , tmp2_path , tmp3_path , tmp4_path :
1615
- with path .open ("w" , encoding = 'utf-8' ) as f :
1616
- f .write (f"I'm { path } and proud of it. Blame test_pathlib.\n " )
1588
+ self .sub2_tree = (self .sub2_path , [], ["tmp3" ])
1589
+ self .createTestHierarchy ()
1617
1590
1618
- if self .can_symlink :
1619
- self .link_path .symlink_to (t2_path , target_is_directory = True )
1620
- broken_link_path .symlink_to ('broken' )
1621
- broken_link2_path .symlink_to (self .cls ('tmp3' , 'broken' ))
1622
- self .sub2_tree = (self .sub2_path , [], ["broken_link" , "broken_link2" , "link" , "tmp3" ])
1623
- else :
1624
- self .sub2_tree = (self .sub2_path , [], ["tmp3" ])
1591
+ def createTestHierarchy (self ):
1592
+ cls = self .cls
1593
+ cls ._files = {
1594
+ f'{ self .base } /TEST1/tmp1' : b'this is tmp1\n ' ,
1595
+ f'{ self .base } /TEST1/SUB1/tmp2' : b'this is tmp2\n ' ,
1596
+ f'{ self .base } /TEST1/SUB2/tmp3' : b'this is tmp3\n ' ,
1597
+ f'{ self .base } /TEST2/tmp4' : b'this is tmp4\n ' ,
1598
+ }
1599
+ cls ._directories = {
1600
+ f'{ self .base } ' : {'TEST1' , 'TEST2' },
1601
+ f'{ self .base } /TEST1' : {'SUB1' , 'SUB2' , 'tmp1' },
1602
+ f'{ self .base } /TEST1/SUB1' : {'SUB11' , 'tmp2' },
1603
+ f'{ self .base } /TEST1/SUB1/SUB11' : set (),
1604
+ f'{ self .base } /TEST1/SUB2' : {'tmp3' },
1605
+ f'{ self .base } /TEST2' : {'tmp4' },
1606
+ }
1625
1607
1626
1608
def tearDown (self ):
1627
- base = self .cls (self .base )
1628
- base ._delete ()
1609
+ cls = self .cls
1610
+ cls ._files .clear ()
1611
+ cls ._directories .clear ()
1629
1612
1630
1613
def test_walk_topdown (self ):
1631
1614
walker = self .walk_path .walk ()
0 commit comments