-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconftest.py
More file actions
76 lines (56 loc) · 1.56 KB
/
conftest.py
File metadata and controls
76 lines (56 loc) · 1.56 KB
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
"""Shared pytest fixtures."""
import os
import tempfile
import pytest
@pytest.fixture
def backend():
"""The storage backend being tested."""
return "rust"
@pytest.fixture
def tmp_db_path(tmp_path):
"""Temporary database path."""
return str(tmp_path / "test.attest")
@pytest.fixture
def tmp_index_path(tmp_path):
"""Temporary embedding index path."""
return str(tmp_path / "test.usearch")
@pytest.fixture
def make_store(tmp_path):
"""Factory fixture: returns a function that creates a RustStore.
Usage:
store = make_store() # uses default path
store = make_store("custom.attest") # uses custom filename
"""
stores = []
def _make(name=None):
from attest_rust import RustStore
path = str(tmp_path / (name or "test.attest"))
store = RustStore(path)
stores.append(store)
return store
yield _make
for s in stores:
try:
s.close()
except Exception:
pass
@pytest.fixture
def make_db(tmp_path):
"""Factory fixture: returns a function that creates AttestDB.
Usage:
db = make_db()
db = make_db(embedding_dim=4)
"""
dbs = []
def _make(name="test", embedding_dim=768, strict=False):
from attestdb.infrastructure.attest_db import AttestDB
path = str(tmp_path / name)
db = AttestDB(path, embedding_dim=embedding_dim, strict=strict)
dbs.append(db)
return db
yield _make
for db in dbs:
try:
db.close()
except Exception:
pass