@@ -15,10 +15,17 @@ def _fillTrashWithJunk(n):
1515 trash = Trash .instance ()
1616 trash .refreshFiles ()
1717 trash .clear ()
18- os .makedirs (trash .trashDir , exist_ok = True )
18+ trash .trashDir .mkdir (parents = True , exist_ok = True )
19+
1920 for i in range (n ):
20- with open (F"{ trash .trashDir } /19991231T235900-test{ i } .txt" , "w" ) as junk :
21- junk .write (F"test{ i } " )
21+ junkPath = Path (trash .trashDir , f"19991231T235900-test{ i } .txt" )
22+
23+ # Alternate between bogus text files and bogus symlinks
24+ if i % 2 == 0 :
25+ junkPath .write_text (f"test{ i } " )
26+ else :
27+ junkPath .symlink_to (trash .trashDir )
28+
2229 trash .refreshFiles ()
2330
2431
@@ -113,16 +120,21 @@ def testTrashFull(tempDir, mainWindow):
113120
114121
115122def testClearTrash (mainWindow ):
116- assert Trash .instance ().count () == 0
123+ trashInstance = Trash .instance ()
124+ assert trashInstance .count () == 0
117125
118126 mainWindow .clearRescueFolder ()
119127 acceptQMessageBox (mainWindow , "no discarded (patches|changes) to delete" )
120128
121129 _fillTrashWithJunk (40 )
122- assert Trash . instance () .count () == 40
130+ assert trashInstance .count () == 40
123131 mainWindow .clearRescueFolder ()
124132 acceptQMessageBox (mainWindow , "delete.+40.+discarded (patches|changes)" )
125- assert Trash .instance ().count () == 0
133+ assert trashInstance .count () == 0
134+
135+ trashInstance .refreshFiles ()
136+ assert trashInstance .count () == 0
137+ assert not list (trashInstance .trashDir .iterdir ())
126138
127139
128140def testOpenTrashFolder (mainWindow ):
0 commit comments