mirror of
https://github.com/codeflash-ai/codeflash-agent.git
synced 2026-05-04 18:25:19 +00:00
* chore: add gitignore entries for local eval repos, e2e fixtures, and env files * fix: restore clean bubble_sort_method.py test fixture The call-site ID commit re-contaminated this file with instrumentation decorators, causing tests to fail with missing CODEFLASH_LOOP_INDEX. * fix: resolve ruff and mypy errors in codeflash-python - Add import-not-found ignores for optional torch/jax imports - Extract magic column index to _STDOUT_COLUMN_INDEX constant - Fix unused variable in _instrument_sync.py - Cast cpu_time_ns to int for mypy arg-type * fix: add skip markers for optional deps and apply ruff formatting to tests Skip torch/jax/tensorflow tests when those packages are not installed. Move has_module helper to conftest.py for reuse across test files. Apply ruff format to all test files that drifted. * fix: resolve remaining ruff format and mypy errors - Add missing blank line in conftest.py (ruff format) - Remove unused import-untyped ignore on jax import (mypy unused-ignore) - Add type: ignore comments for object-typed SQLite row values * chore: bump codeflash-python to 0.1.1.dev0
27 lines
777 B
Python
27 lines
777 B
Python
"""Shared test fixtures for codeflash-python tests."""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from importlib.util import find_spec
|
|
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
|
|
|
|
|
|
# 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)
|