|
10 | 10 | from .test_local import csv_files, filetexts
|
11 | 11 |
|
12 | 12 |
|
13 |
| -def test_is_async(): |
| 13 | +@pytest.mark.asyncio |
| 14 | +async def test_is_async_default(): |
14 | 15 | fs = fsspec.filesystem("file")
|
15 | 16 | async_fs = AsyncFileSystemWrapper(fs)
|
16 | 17 | assert async_fs.async_impl
|
| 18 | + assert async_fs.asynchronous |
| 19 | + async_fs = AsyncFileSystemWrapper(fs, asynchronous=False) |
| 20 | + assert not async_fs.asynchronous |
17 | 21 |
|
18 | 22 |
|
19 | 23 | def test_class_wrapper():
|
@@ -53,6 +57,7 @@ async def test_cats():
|
53 | 57 | assert result == b"a,b\n1,2\n"[1:-2]
|
54 | 58 |
|
55 | 59 | # test synchronous API is available as expected
|
| 60 | + async_fs = AsyncFileSystemWrapper(fs, asynchronous=False) |
56 | 61 | result = async_fs.cat(".test.fakedata.1.csv", start=1, end=-2)
|
57 | 62 | assert result == b"a,b\n1,2\n"[1:-2]
|
58 | 63 |
|
@@ -142,3 +147,17 @@ async def test_batch_operations():
|
142 | 147 | await async_fs._rm([".test.fakedata.1.csv", ".test.fakedata.2.csv"])
|
143 | 148 | assert not await async_fs._exists(".test.fakedata.1.csv")
|
144 | 149 | assert not await async_fs._exists(".test.fakedata.2.csv")
|
| 150 | + |
| 151 | + |
| 152 | +def test_open(tmpdir): |
| 153 | + fn = f"{tmpdir}/afile" |
| 154 | + with open(fn, "wb") as f: |
| 155 | + f.write(b"hello") |
| 156 | + of = fsspec.open( |
| 157 | + "dir://afile::async_wrapper::file", |
| 158 | + mode="rb", |
| 159 | + async_wrapper={"asynchronous": False}, |
| 160 | + dir={"path": str(tmpdir)}, |
| 161 | + ) |
| 162 | + with of as f: |
| 163 | + assert f.read() == b"hello" |
0 commit comments