free-claude-code/smoke/conftest.py
Alishahryar1 751694a5da Refactor smoke testing framework and enhance provider configurations
- Updated DEFAULT_TARGETS in config.py to include new targets: clients, llamacpp, and lmstudio, while removing contract and optimizations.
- Introduced TARGET_ALIASES for better target management.
- Added TARGET_REQUIRED_ENV to specify environment variables needed for each target.
- Enhanced SmokeOutcome in report.py to include classification of outcomes for better reporting.
- Implemented classify_outcome function to categorize smoke test results.
- Added new test for stop endpoint in test_api_live.py to ensure proper error handling.
- Updated test_auth_live.py to enforce auth token requirements and utilize environment files.
- Changed target from vscode to clients in test_client_shapes_live.py.
- Removed obsolete test_feature_manifest.py and test_stream_contracts.py files.
- Added new skip helpers in skips.py to manage upstream unavailability scenarios.
- Created new tests for local provider endpoints in test_local_provider_endpoints_live.py.
- Added comprehensive feature inventory tests in tests/contracts/test_feature_manifest.py.
- Implemented stream contract tests in tests/contracts/test_stream_contracts.py.
2026-04-24 17:16:06 -07:00

77 lines
2.1 KiB
Python

from __future__ import annotations
from collections.abc import Iterator
import pytest
from smoke.lib.config import SmokeConfig, auth_headers
from smoke.lib.report import SmokeReport
from smoke.lib.server import RunningServer, start_server
def pytest_collection_modifyitems(items: list[pytest.Item]) -> None:
if SmokeConfig.load().live:
return
skip = pytest.mark.skip(reason="set FCC_LIVE_SMOKE=1 to run local smoke tests")
for item in items:
item.add_marker(skip)
def pytest_configure(config: pytest.Config) -> None:
global _REPORT
smoke_config = SmokeConfig.load()
_REPORT = SmokeReport(smoke_config)
def pytest_runtest_setup(item: pytest.Item) -> None:
config = SmokeConfig.load()
target_marks = list(item.iter_markers("smoke_target"))
if not target_marks:
return
targets = [str(mark.args[0]) for mark in target_marks if mark.args]
if targets and not any(config.target_enabled(target) for target in targets):
pytest.skip(f"smoke target disabled: {', '.join(targets)}")
def pytest_runtest_logreport(report: pytest.TestReport) -> None:
if report.when == "setup" and not report.skipped:
return
if report.when == "teardown" and not report.failed:
return
if _REPORT is None:
return
markers = sorted(
str(name) for name in report.keywords if str(name).startswith("smoke_")
)
detail = "" if report.longrepr is None else str(report.longrepr)
_REPORT.add(
nodeid=report.nodeid,
outcome=report.outcome,
duration_s=report.duration,
markers=markers,
detail=detail,
)
def pytest_sessionfinish(session: pytest.Session, exitstatus: int) -> None:
if _REPORT is not None:
_REPORT.write()
@pytest.fixture(scope="session")
def smoke_config() -> SmokeConfig:
return SmokeConfig.load()
@pytest.fixture
def smoke_server(smoke_config: SmokeConfig) -> Iterator[RunningServer]:
with start_server(smoke_config) as server:
yield server
@pytest.fixture
def smoke_headers() -> dict[str, str]:
return auth_headers()
_REPORT: SmokeReport | None = None