Skip to content

Commit 5666478

Browse files
committed
fixup for win
1 parent 0315e0b commit 5666478

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

tests/test_store/test_zep8.py

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,21 +1920,21 @@ async def test_zip_adapter_missing_coverage() -> None:
19201920
assert schemes == []
19211921

19221922
# Test ZIP with storage options (should ignore them)
1923-
with tempfile.NamedTemporaryFile(suffix=".zip", delete=False) as tmp:
1924-
tmp_path = tmp.name
1923+
with tempfile.TemporaryDirectory() as temp_dir:
1924+
tmp_path = Path(temp_dir) / "test.zip"
19251925

1926-
# Create a zip file with zarr data
1927-
with zipfile.ZipFile(tmp_path, "w") as zf:
1928-
zf.writestr(".zgroup", "{}") # Valid zarr group
1926+
# Create a zip file with zarr data
1927+
with zipfile.ZipFile(tmp_path, "w") as zf:
1928+
zf.writestr(".zgroup", "{}") # Valid zarr group
19291929

1930-
try:
19311930
segment = URLSegment(adapter="zip", path="")
19321931
result = await ZipAdapter.from_url_segment(
19331932
segment, f"file:{tmp_path}", storage_options={"some_option": "value"}
19341933
)
19351934
assert result is not None
1936-
finally:
1937-
Path(tmp_path).unlink(missing_ok=True)
1935+
# Close the store to release the file handle on Windows
1936+
result.close()
1937+
# File will be automatically cleaned up when temp_dir is removed
19381938

19391939

19401940
async def test_logging_adapter_missing_coverage() -> None:
@@ -2494,10 +2494,9 @@ async def test_zip_adapter_remote_functionality() -> None:
24942494
segment = URLSegment(adapter="zip", path="inner")
24952495

24962496
# Create a temporary zip file to test with
2497-
with tempfile.NamedTemporaryFile(suffix=".zip", delete=False) as tmp:
2498-
tmp_path = tmp.name
2497+
with tempfile.TemporaryDirectory() as temp_dir:
2498+
tmp_path = Path(temp_dir) / "test.zip"
24992499

2500-
try:
25012500
# Create a valid zip file
25022501
with zipfile.ZipFile(tmp_path, "w") as zf:
25032502
zf.writestr(".zgroup", "{}")
@@ -2506,9 +2505,9 @@ async def test_zip_adapter_remote_functionality() -> None:
25062505
# Test with file: URL (should convert to local path)
25072506
result = await ZipAdapter.from_url_segment(segment, f"file:{tmp_path}")
25082507
assert result is not None
2509-
2510-
finally:
2511-
Path(tmp_path).unlink(missing_ok=True)
2508+
# Close the store to release the file handle on Windows
2509+
result.close()
2510+
# File will be automatically cleaned up when temp_dir is removed
25122511

25132512

25142513
async def test_zip_adapter_remote_error_handling() -> None:

0 commit comments

Comments
 (0)