-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
26 lines (20 loc) · 841 Bytes
/
conftest.py
File metadata and controls
26 lines (20 loc) · 841 Bytes
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
import os
import tempfile
from collections.abc import Iterator
from pathlib import Path
import pytest
# from ingest import memory # TODO: Fix missing ingest module
@pytest.fixture(scope="session", autouse=True)
def _in_memory_db() -> Iterator[None]:
"""
Share one SQLite in-memory database across the whole test run.
The URI form + `cache=shared` ensures every new sqlite3 connection
opened by the code under test points to *the same* DB instance.
"""
# Create a temporary file that will be deleted when the session ends
temp_fd, temp_path = tempfile.mkstemp(suffix=".db")
os.close(temp_fd) # Close the file descriptor, we only need the path
# with memory.use_db(shared_memory_db_uri): # TODO: Fix missing ingest module
yield
if Path(temp_path).exists():
Path(temp_path).unlink()