-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconftest.py
More file actions
46 lines (32 loc) · 1.15 KB
/
conftest.py
File metadata and controls
46 lines (32 loc) · 1.15 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
"""Pytest configuration and fixtures for Drift Python SDK tests."""
from __future__ import annotations
import os
import tempfile
from collections.abc import Generator
from pathlib import Path
from typing import TYPE_CHECKING
import pytest
if TYPE_CHECKING:
from drift.core.metrics import MetricsCollector
from drift.core.tracing.adapters import InMemorySpanAdapter
@pytest.fixture
def temp_dir() -> Generator[Path, None, None]:
"""Create a temporary directory for test files."""
with tempfile.TemporaryDirectory() as tmpdir:
yield Path(tmpdir)
@pytest.fixture
def original_cwd() -> Generator[str, None, None]:
"""Save and restore the current working directory."""
cwd = os.getcwd()
yield cwd
os.chdir(cwd)
@pytest.fixture
def in_memory_adapter() -> InMemorySpanAdapter:
"""Create a fresh InMemorySpanAdapter for testing."""
from drift.core.tracing.adapters import InMemorySpanAdapter
return InMemorySpanAdapter()
@pytest.fixture
def metrics_collector() -> MetricsCollector:
"""Create a fresh MetricsCollector for testing."""
from drift.core.metrics import MetricsCollector
return MetricsCollector()