litellm/tests/rust-python-harness/strategies/unit_tests_parity/runner.py
yujonglee ee08c36fc0
refactor(tests): restructure rust python harness around strategy definitions (#39628)
* wip

* refactor(tests): move sdk function tracing into rust python harness

* dead code

* fix: handle harness keyboard interrupts

* refactor(tests): deduplicate rust python harness helpers

* fix(harness): expose validated strategy choices

* wip

* refactor(harness): let strategies own parity reports

* docs(harness): update strategy structure

* refactor(harness): localize strategy report views

* wip

* fix(harness): satisfy mapping runner type checks

* fix(harness): clarify trace parity output

* wip

* fix(harness): clarify unit mapping report

* fix(harness): finalize trace parity contracts

* refactor(harness): structure parity contracts

* feat: derive unit test mapping from traces

* feat(harness): map rstest test families

* feat(ocr): port Azure document intelligence tests

* feat(harness): enforce complete unit mappings

* feat(ocr): add reducto core transforms

* feat(harness): classify host-only unit tests

* fix(ocr): complete Rust provider plumbing

* fix(harness): reuse OCR parity workers
2026-09-03 21:15:01 -07:00

36 lines
1.3 KiB
Python

from __future__ import annotations
from collections.abc import Sequence
from pathlib import Path
from typing import Final
from pydantic import BaseModel, ConfigDict
from ...shared.unit_runners.python_runner import BackendSpec, compare_python_runs, run_python_tests
from ...shared.unit_runners.suite_runner import SuiteExecution
BACKEND: Final = BackendSpec(environment_variable="LITELLM_RUST")
class UnitParityExclusion(BaseModel):
model_config = ConfigDict(frozen=True, extra="forbid")
nodeid: str
reason: str
class UnitParitySuite(BaseModel):
model_config = ConfigDict(frozen=True, extra="forbid")
python_selectors: tuple[str, ...]
exclusions: tuple[UnitParityExclusion, ...] = ()
def run_suite(suite: UnitParitySuite, repo_root: Path, pytest_args: Sequence[str] = ()) -> SuiteExecution:
if not suite.python_selectors:
return SuiteExecution(problems=("unit parity suites must select Python tests",))
deselections: Final = tuple(f"--deselect={exclusion.nodeid}" for exclusion in suite.exclusions)
args: Final = (*pytest_args, *deselections)
python: Final = run_python_tests(suite.python_selectors, repo_root, "python", BACKEND, args)
rust: Final = run_python_tests(suite.python_selectors, repo_root, "rust", BACKEND, args)
return SuiteExecution(problems=compare_python_runs(python, rust))