Skip to content

Commit 415a0ce

Browse files
authored
test: Fix storage_client fixture cleanup (#1841)
1 parent cf6737c commit 415a0ce

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

tests/unit/storages/conftest.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,16 @@
1414
)
1515

1616
if TYPE_CHECKING:
17+
from collections.abc import AsyncGenerator
18+
1719
from fakeredis import FakeAsyncRedis
1820

1921

2022
@pytest.fixture(params=['memory', 'file_system', 'sql', 'redis'])
21-
def storage_client(
23+
async def storage_client(
2224
request: pytest.FixtureRequest,
2325
redis_client: FakeAsyncRedis,
24-
) -> StorageClient:
26+
) -> AsyncGenerator[StorageClient, None]:
2527
"""Parameterized fixture to test with different storage clients."""
2628
storage_client: StorageClient
2729

@@ -36,4 +38,7 @@ def storage_client(
3638
else:
3739
storage_client = FileSystemStorageClient()
3840
service_locator.set_storage_client(storage_client)
39-
return storage_client
41+
yield storage_client
42+
43+
if isinstance(storage_client, SqlStorageClient):
44+
await storage_client.close()

0 commit comments

Comments
 (0)