Skip to content

Commit 0f58ac0

Browse files
orenlmartindurant
andauthored
Add missing open_async() to DirFileSystem (fixes #1698) (#1699)
Co-authored-by: Martin Durant <[email protected]>
1 parent b842cf4 commit 0f58ac0

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

fsspec/implementations/dirfs.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,3 +370,15 @@ def open(
370370
*args,
371371
**kwargs,
372372
)
373+
374+
async def open_async(
375+
self,
376+
path,
377+
*args,
378+
**kwargs,
379+
):
380+
return await self.fs.open_async(
381+
self._join(path),
382+
*args,
383+
**kwargs,
384+
)

fsspec/implementations/tests/test_dirfs.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,16 @@ def test_sign(mocker, dirfs):
589589
dirfs.fs.sign.assert_called_once_with(f"{PATH}/file", *ARGS, **KWARGS)
590590

591591

592+
@pytest.mark.asyncio
593+
async def test_open_async(mocker, adirfs):
594+
adirfs.fs.open_async = mocker.AsyncMock()
595+
assert (
596+
await adirfs.open_async("file", *ARGS, **KWARGS)
597+
== adirfs.fs.open_async.return_value
598+
)
599+
adirfs.fs.open_async.assert_called_once_with(f"{PATH}/file", *ARGS, **KWARGS)
600+
601+
592602
def test_open(mocker, dirfs):
593603
dirfs.fs.open = mocker.Mock()
594604
assert dirfs.open("file", *ARGS, **KWARGS) == dirfs.fs.open.return_value

0 commit comments

Comments
 (0)