@@ -205,3 +205,42 @@ async def test_async_streamed_file_read():
205205 == b"foo-bar" * 20
206206 )
207207 await streamed_file .close ()
208+
209+
210+ def test_rm_file_with_rm_implementation ():
211+ class AsyncFSWithRm (fsspec .asyn .AsyncFileSystem ):
212+ def __init__ (self , ** kwargs ):
213+ super ().__init__ (** kwargs )
214+ self .removed_paths = []
215+
216+ async def _rm (self , path , recursive = False , batch_size = None , ** kwargs ):
217+ if isinstance (path , str ):
218+ path = [path ]
219+ for p in path :
220+ self .removed_paths .append (p )
221+ return None
222+
223+ fs = AsyncFSWithRm ()
224+ fs .rm_file ("test/file.txt" )
225+ assert "test/file.txt" in fs .removed_paths
226+
227+
228+ def test_rm_file_with_rm_file_implementation ():
229+ class AsyncFSWithRmFile (fsspec .asyn .AsyncFileSystem ):
230+ def __init__ (self , ** kwargs ):
231+ super ().__init__ (** kwargs )
232+ self .removed_paths = []
233+
234+ async def _rm_file (self , path , ** kwargs ):
235+ self .removed_paths .append (path )
236+ return None
237+
238+ fs = AsyncFSWithRmFile ()
239+ fs .rm_file ("test/file.txt" )
240+ assert "test/file.txt" in fs .removed_paths
241+
242+
243+ def test_rm_file_without_implementation ():
244+ fs = fsspec .asyn .AsyncFileSystem ()
245+ with pytest .raises (NotImplementedError ):
246+ fs .rm_file ("test/file.txt" )
0 commit comments