Skip to content

Commit a5edd1a

Browse files
authored
Merge 1367c5c into 20e58e0
2 parents 20e58e0 + 1367c5c commit a5edd1a

File tree

6 files changed

+24
-58
lines changed

6 files changed

+24
-58
lines changed

key-value/key-value-aio/tests/stores/disk/test_disk.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,15 @@
1515

1616

1717
class TestDiskStore(ContextManagerStoreTestMixin, BaseStoreTests):
18-
@pytest.fixture(scope="session")
19-
async def disk_store(self) -> AsyncGenerator[DiskStore, None]:
20-
with tempfile.TemporaryDirectory() as temp_dir:
21-
yield DiskStore(directory=temp_dir, max_size=TEST_SIZE_LIMIT)
22-
2318
@override
2419
@pytest.fixture
25-
async def store(self, disk_store: DiskStore) -> DiskStore:
26-
disk_store._cache.clear() # pyright: ignore[reportPrivateUsage]
27-
28-
return disk_store
20+
async def store(self) -> AsyncGenerator[DiskStore, None]:
21+
with tempfile.TemporaryDirectory() as temp_dir:
22+
yield DiskStore(directory=temp_dir, max_size=TEST_SIZE_LIMIT)
2923

3024
@pytest.fixture
31-
async def disk_cache(self, disk_store: DiskStore) -> Cache:
32-
return disk_store._cache # pyright: ignore[reportPrivateUsage]
25+
async def disk_cache(self, store: DiskStore) -> Cache:
26+
return store._cache # pyright: ignore[reportPrivateUsage]
3327

3428
async def test_value_stored(self, store: DiskStore, disk_cache: Cache):
3529
await store.put(collection="test", key="test_key", value={"name": "Alice", "age": 30})

key-value/key-value-aio/tests/stores/disk/test_multi_disk.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,11 @@
1919

2020

2121
class TestMultiDiskStore(ContextManagerStoreTestMixin, BaseStoreTests):
22-
@pytest.fixture(scope="session")
23-
async def multi_disk_store(self) -> AsyncGenerator[MultiDiskStore, None]:
24-
with tempfile.TemporaryDirectory() as temp_dir:
25-
yield MultiDiskStore(base_directory=Path(temp_dir), max_size=TEST_SIZE_LIMIT)
26-
2722
@override
2823
@pytest.fixture
29-
async def store(self, multi_disk_store: MultiDiskStore) -> MultiDiskStore:
30-
for collection in multi_disk_store._cache: # pyright: ignore[reportPrivateUsage]
31-
multi_disk_store._cache[collection].clear() # pyright: ignore[reportPrivateUsage]
32-
33-
return multi_disk_store
24+
async def store(self) -> AsyncGenerator[MultiDiskStore, None]:
25+
with tempfile.TemporaryDirectory() as temp_dir:
26+
yield MultiDiskStore(base_directory=Path(temp_dir), max_size=TEST_SIZE_LIMIT)
3427

3528
async def test_value_stored(self, store: MultiDiskStore):
3629
await store.put(collection="test", key="test_key", value={"name": "Alice", "age": 30})

key-value/key-value-aio/tests/stores/duckdb/test_duckdb.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,9 @@ def get_client_from_store(store: DuckDBStore) -> DuckDBPyConnection:
2020
class TestDuckDBStore(ContextManagerStoreTestMixin, BaseStoreTests):
2121
@override
2222
@pytest.fixture
23-
async def store(self) -> AsyncGenerator[DuckDBStore, None]:
23+
async def store(self) -> DuckDBStore:
2424
"""Test with in-memory DuckDB database."""
25-
duckdb_store = DuckDBStore()
26-
yield duckdb_store
27-
await duckdb_store.close()
25+
return DuckDBStore()
2826

2927
@pytest.mark.skip(reason="Local disk stores are unbounded")
3028
async def test_not_unbounded(self, store: BaseStore): ...
@@ -38,9 +36,7 @@ async def store(self) -> AsyncGenerator[DuckDBStore, None]:
3836
"""Test with persistent DuckDB database file."""
3937
with TemporaryDirectory() as temp_dir:
4038
db_path = Path(temp_dir) / "test.db"
41-
duckdb_store = DuckDBStore(database_path=db_path)
42-
yield duckdb_store
43-
await duckdb_store.close()
39+
yield DuckDBStore(database_path=db_path)
4440

4541
@pytest.mark.skip(reason="Local disk stores are unbounded")
4642
async def test_not_unbounded(self, store: BaseStore): ...
@@ -55,7 +51,7 @@ async def store(self) -> AsyncGenerator[DuckDBStore, None]:
5551
"""Provide DuckDB store instance."""
5652
duckdb_store = DuckDBStore()
5753
yield duckdb_store
58-
await duckdb_store.close()
54+
await duckdb_store.close() # This class doesn't use ContextManagerStoreTestMixin
5955

6056
async def test_native_sql_queryability(self):
6157
"""Test that users can query the database directly with SQL."""

key-value/key-value-sync/tests/code_gen/stores/disk/test_disk.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,15 @@
1818

1919

2020
class TestDiskStore(ContextManagerStoreTestMixin, BaseStoreTests):
21-
@pytest.fixture(scope="session")
22-
def disk_store(self) -> Generator[DiskStore, None, None]:
23-
with tempfile.TemporaryDirectory() as temp_dir:
24-
yield DiskStore(directory=temp_dir, max_size=TEST_SIZE_LIMIT)
25-
2621
@override
2722
@pytest.fixture
28-
def store(self, disk_store: DiskStore) -> DiskStore:
29-
disk_store._cache.clear() # pyright: ignore[reportPrivateUsage]
30-
31-
return disk_store
23+
def store(self) -> Generator[DiskStore, None, None]:
24+
with tempfile.TemporaryDirectory() as temp_dir:
25+
yield DiskStore(directory=temp_dir, max_size=TEST_SIZE_LIMIT)
3226

3327
@pytest.fixture
34-
def disk_cache(self, disk_store: DiskStore) -> Cache:
35-
return disk_store._cache # pyright: ignore[reportPrivateUsage]
28+
def disk_cache(self, store: DiskStore) -> Cache:
29+
return store._cache # pyright: ignore[reportPrivateUsage]
3630

3731
def test_value_stored(self, store: DiskStore, disk_cache: Cache):
3832
store.put(collection="test", key="test_key", value={"name": "Alice", "age": 30})

key-value/key-value-sync/tests/code_gen/stores/disk/test_multi_disk.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,11 @@
2222

2323

2424
class TestMultiDiskStore(ContextManagerStoreTestMixin, BaseStoreTests):
25-
@pytest.fixture(scope="session")
26-
def multi_disk_store(self) -> Generator[MultiDiskStore, None, None]:
27-
with tempfile.TemporaryDirectory() as temp_dir:
28-
yield MultiDiskStore(base_directory=Path(temp_dir), max_size=TEST_SIZE_LIMIT)
29-
3025
@override
3126
@pytest.fixture
32-
def store(self, multi_disk_store: MultiDiskStore) -> MultiDiskStore:
33-
for collection in multi_disk_store._cache: # pyright: ignore[reportPrivateUsage]
34-
multi_disk_store._cache[collection].clear() # pyright: ignore[reportPrivateUsage]
35-
36-
return multi_disk_store
27+
def store(self) -> Generator[MultiDiskStore, None, None]:
28+
with tempfile.TemporaryDirectory() as temp_dir:
29+
yield MultiDiskStore(base_directory=Path(temp_dir), max_size=TEST_SIZE_LIMIT)
3730

3831
def test_value_stored(self, store: MultiDiskStore):
3932
store.put(collection="test", key="test_key", value={"name": "Alice", "age": 30})

key-value/key-value-sync/tests/code_gen/stores/duckdb/test_duckdb.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ def get_client_from_store(store: DuckDBStore) -> DuckDBPyConnection:
2323
class TestDuckDBStore(ContextManagerStoreTestMixin, BaseStoreTests):
2424
@override
2525
@pytest.fixture
26-
def store(self) -> Generator[DuckDBStore, None, None]:
26+
def store(self) -> DuckDBStore:
2727
"""Test with in-memory DuckDB database."""
28-
duckdb_store = DuckDBStore()
29-
yield duckdb_store
30-
duckdb_store.close()
28+
return DuckDBStore()
3129

3230
@pytest.mark.skip(reason="Local disk stores are unbounded")
3331
def test_not_unbounded(self, store: BaseStore): ...
@@ -41,9 +39,7 @@ def store(self) -> Generator[DuckDBStore, None, None]:
4139
"""Test with persistent DuckDB database file."""
4240
with TemporaryDirectory() as temp_dir:
4341
db_path = Path(temp_dir) / "test.db"
44-
duckdb_store = DuckDBStore(database_path=db_path)
45-
yield duckdb_store
46-
duckdb_store.close()
42+
yield DuckDBStore(database_path=db_path)
4743

4844
@pytest.mark.skip(reason="Local disk stores are unbounded")
4945
def test_not_unbounded(self, store: BaseStore): ...
@@ -58,7 +54,7 @@ def store(self) -> Generator[DuckDBStore, None, None]:
5854
"""Provide DuckDB store instance."""
5955
duckdb_store = DuckDBStore()
6056
yield duckdb_store
61-
duckdb_store.close()
57+
duckdb_store.close() # This class doesn't use ContextManagerStoreTestMixin
6258

6359
def test_native_sql_queryability(self):
6460
"""Test that users can query the database directly with SQL."""

0 commit comments

Comments
 (0)