Skip to content

Commit 48a97d3

Browse files
committed
Make file I/O asynchronous
1 parent 910d24a commit 48a97d3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

tests/test_application.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import shutil
44
from pathlib import Path
55

6+
import anyio
67
import httpx
78
import pytest
89
from asgi_lifespan import LifespanManager
@@ -23,10 +24,11 @@ def anyio_backend():
2324

2425
async def test_application(tmp_path, anyio_backend):
2526
src_dir = tmp_path / "docs"
26-
index_file = src_dir / "index.rst"
2727
out_dir = tmp_path / "build"
2828
shutil.copytree(ROOT / "docs", tmp_path / "docs")
2929
out_dir.mkdir(parents=True, exist_ok=True)
30+
index_file = anyio.Path(src_dir / "index.rst")
31+
await index_file.write_text("hello")
3032

3133
url_host = "127.0.0.1:7777"
3234
ignore_handler = IgnoreFilter([out_dir], [])
@@ -47,8 +49,7 @@ async def test_application(tmp_path, anyio_backend):
4749
assert response.status_code == 200
4850

4951
async with aconnect_ws("/websocket-reload", client) as websocket:
50-
with index_file.open("a") as f:
51-
f.write("hello")
52+
await index_file.write_text("world")
5253

5354
data = await websocket.receive_text()
5455
assert data == "refresh"

0 commit comments

Comments
 (0)