Skip to content

Commit 4bb78cf

Browse files
committed
Try to get Windows tests passing
1 parent 201ebfd commit 4bb78cf

File tree

6 files changed

+44
-30
lines changed

6 files changed

+44
-30
lines changed

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
import tempfile
33
from collections.abc import AsyncGenerator
4+
from pathlib import Path
45

56
import pytest
67
from dirty_equals import IsDatetime
@@ -15,21 +16,24 @@
1516

1617

1718
class TestDiskStore(ContextManagerStoreTestMixin, BaseStoreTests):
18-
@pytest.fixture(scope="session")
19-
async def disk_store(self) -> AsyncGenerator[DiskStore, None]:
19+
@pytest.fixture(scope="class")
20+
async def disk_path(self) -> AsyncGenerator[Path, None]:
2021
with tempfile.TemporaryDirectory() as temp_dir:
21-
yield DiskStore(directory=temp_dir, max_size=TEST_SIZE_LIMIT)
22+
yield Path(temp_dir)
2223

2324
@override
2425
@pytest.fixture
25-
async def store(self, disk_store: DiskStore) -> DiskStore:
26+
async def store(self, disk_path: Path) -> DiskStore:
27+
disk_store = DiskStore(directory=disk_path, max_size=TEST_SIZE_LIMIT)
28+
2629
disk_store._cache.clear() # pyright: ignore[reportPrivateUsage]
2730

2831
return disk_store
2932

3033
@pytest.fixture
31-
async def disk_cache(self, disk_store: DiskStore) -> Cache:
32-
return disk_store._cache # pyright: ignore[reportPrivateUsage]
34+
async def disk_cache(self, store: DiskStore) -> Cache:
35+
assert isinstance(store._cache, Cache)
36+
return store._cache # pyright: ignore[reportPrivateUsage]
3337

3438
async def test_value_stored(self, store: DiskStore, disk_cache: Cache):
3539
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: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,21 @@
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)
22+
@pytest.fixture
23+
async def multi_disk_path(self) -> AsyncGenerator[Path, None]:
24+
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as temp_dir:
25+
yield Path(temp_dir)
2626

2727
@override
2828
@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]
29+
async def store(self, multi_disk_path: Path) -> AsyncGenerator[MultiDiskStore, None]:
30+
store = MultiDiskStore(base_directory=multi_disk_path, max_size=TEST_SIZE_LIMIT)
31+
32+
yield store
3233

33-
return multi_disk_store
34+
# Wipe the store after returning it
35+
for collection in store._cache: # pyright: ignore[reportPrivateUsage]
36+
store._cache[collection].clear() # pyright: ignore[reportPrivateUsage]
3437

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

key-value/key-value-aio/tests/stores/rocksdb/test_rocksdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
@pytest.mark.filterwarnings("ignore:A configured store is unstable and may change in a backwards incompatible way. Use at your own risk.")
1818
class TestRocksDBStore(ContextManagerStoreTestMixin, BaseStoreTests):
19-
@pytest.fixture(scope="session")
19+
@pytest.fixture(scope="class")
2020
async def rocksdb_path(self) -> AsyncGenerator[Path, None]:
2121
with TemporaryDirectory() as temp_dir:
2222
db_path = Path(temp_dir) / "test_db"

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import json
55
import tempfile
66
from collections.abc import Generator
7+
from pathlib import Path
78

89
import pytest
910
from dirty_equals import IsDatetime
@@ -18,21 +19,24 @@
1819

1920

2021
class TestDiskStore(ContextManagerStoreTestMixin, BaseStoreTests):
21-
@pytest.fixture(scope="session")
22-
def disk_store(self) -> Generator[DiskStore, None, None]:
22+
@pytest.fixture(scope="class")
23+
def disk_path(self) -> Generator[Path, None, None]:
2324
with tempfile.TemporaryDirectory() as temp_dir:
24-
yield DiskStore(directory=temp_dir, max_size=TEST_SIZE_LIMIT)
25+
yield Path(temp_dir)
2526

2627
@override
2728
@pytest.fixture
28-
def store(self, disk_store: DiskStore) -> DiskStore:
29+
def store(self, disk_path: Path) -> DiskStore:
30+
disk_store = DiskStore(directory=disk_path, max_size=TEST_SIZE_LIMIT)
31+
2932
disk_store._cache.clear() # pyright: ignore[reportPrivateUsage]
3033

3134
return disk_store
3235

3336
@pytest.fixture
34-
def disk_cache(self, disk_store: DiskStore) -> Cache:
35-
return disk_store._cache # pyright: ignore[reportPrivateUsage]
37+
def disk_cache(self, store: DiskStore) -> Cache:
38+
assert isinstance(store._cache, Cache)
39+
return store._cache # pyright: ignore[reportPrivateUsage]
3640

3741
def test_value_stored(self, store: DiskStore, disk_cache: Cache):
3842
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: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,21 @@
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)
25+
@pytest.fixture
26+
def multi_disk_path(self) -> Generator[Path, None, None]:
27+
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as temp_dir:
28+
yield Path(temp_dir)
2929

3030
@override
3131
@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]
32+
def store(self, multi_disk_path: Path) -> Generator[MultiDiskStore, None, None]:
33+
store = MultiDiskStore(base_directory=multi_disk_path, max_size=TEST_SIZE_LIMIT)
34+
35+
yield store
3536

36-
return multi_disk_store
37+
# Wipe the store after returning it
38+
for collection in store._cache: # pyright: ignore[reportPrivateUsage]
39+
store._cache[collection].clear() # pyright: ignore[reportPrivateUsage]
3740

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

key-value/key-value-sync/tests/code_gen/stores/rocksdb/test_rocksdb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
@pytest.mark.filterwarnings("ignore:A configured store is unstable and may change in a backwards incompatible way. Use at your own risk.")
2121
class TestRocksDBStore(ContextManagerStoreTestMixin, BaseStoreTests):
22-
@pytest.fixture(scope="session")
22+
@pytest.fixture(scope="class")
2323
def rocksdb_path(self) -> Generator[Path, None, None]:
2424
with TemporaryDirectory() as temp_dir:
2525
db_path = Path(temp_dir) / "test_db"

0 commit comments

Comments
 (0)