-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconftest.py
30 lines (23 loc) · 872 Bytes
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import contextlib
import uuid
from pathlib import Path
from typing import Generator
import pytest
from triplestore.classes import TripleStore
@pytest.fixture
def clean_file(tmp_path) -> Generator[Path, None, None]:
unique_index_path = tmp_path / f"bplustree-testfile-{uuid.uuid4()}.index"
wal_path = unique_index_path.with_name(f"{unique_index_path.name}-wal")
yield unique_index_path
# Ensure the file is closed before attempting to delete it
with contextlib.suppress(PermissionError):
if unique_index_path.is_file():
unique_index_path.unlink()
if wal_path.is_file():
wal_path.unlink()
for file in tmp_path.glob("bplustree-testfile-*.index*"):
with contextlib.suppress(PermissionError):
file.unlink()
@pytest.fixture
def store():
return TripleStore(kv_store={}, relations={})