Skip to content

Commit 14a310d

Browse files
committed
test: fix ASYNC240 — avoid pathlib in async DummyUploadedFile.save
Use asyncio.to_thread with a sync helper for test file writes.
1 parent 27f9d8b commit 14a310d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

test/testcases/test_web_api/test_conversation_app/test_conversation_routes_unit.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
import pytest
2626

2727

28+
def _write_upload_test_bytes(path: str) -> None:
29+
"""Sync write for _DummyUploadedFile.save (keeps pathlib out of async def for ASYNC240)."""
30+
Path(path).write_bytes(b"audio-bytes")
31+
32+
2833
class _DummyManager:
2934
def route(self, *_args, **_kwargs):
3035
def decorator(func):
@@ -96,7 +101,7 @@ def __init__(self, filename):
96101

97102
async def save(self, path):
98103
self.saved_path = path
99-
Path(path).write_bytes(b"audio-bytes")
104+
await asyncio.to_thread(_write_upload_test_bytes, path)
100105

101106

102107
def _run(coro):

0 commit comments

Comments
 (0)