codeflash-agent/packages/codeflash-python/tests/conftest.py

28 lines
777 B
Python
Raw Normal View History

2026-04-03 22:36:50 +00:00
"""Shared test fixtures for codeflash-python tests."""
from __future__ import annotations
import sys
from importlib.util import find_spec
2026-04-03 22:36:50 +00:00
from pathlib import Path
import pytest
def has_module(name: str) -> bool:
"""Check whether an optional dependency is importable (for skipif markers)."""
return find_spec(name) is not None
2026-04-03 22:36:50 +00:00
# Make the code_to_optimize fixture package importable by tests that need it
# (e.g. test_comparator.py, test_trace_benchmarks.py).
_TESTS_DIR = str(Path(__file__).resolve().parent)
if _TESTS_DIR not in sys.path:
sys.path.insert(0, _TESTS_DIR)
@pytest.fixture
def benchmark():
"""Passthrough benchmark fixture matching the codeflash-benchmark plugin fallback."""
return lambda func, *args, **kwargs: func(*args, **kwargs)