Files
wehub-resource-sync 97e91a83f3
Ruff / Ruff (push) Waiting to run
Test / Core Tests (push) Waiting to run
Test / Offline Coverage Tests (Python 3.10) (push) Waiting to run
Test / Offline Coverage Tests (Python 3.11) (push) Waiting to run
Test / Offline Coverage Tests (Python 3.12) (push) Waiting to run
Test / Offline Coverage Tests (Python 3.13) (push) Waiting to run
Test / Offline Coverage Tests (Python 3.9) (push) Waiting to run
Test / Full Coverage (Python 3.11) (push) Waiting to run
Test / Core Provider Tests (OpenAI) (push) Blocked by required conditions
Test / Core Provider Tests (Anthropic) (push) Blocked by required conditions
Test / Core Provider Tests (Google) (push) Blocked by required conditions
Test / Core Provider Tests (Other) (push) Blocked by required conditions
Test / Anthropic Tests (push) Blocked by required conditions
Test / Gemini Tests (push) Blocked by required conditions
Test / Google GenAI Tests (push) Blocked by required conditions
Test / Vertex AI Tests (push) Blocked by required conditions
Test / OpenAI Tests (push) Blocked by required conditions
Test / Writer Tests (push) Blocked by required conditions
Test / Auto Client Tests (push) Blocked by required conditions
ty / type-check (push) Waiting to run
chore: import upstream snapshot with attribution
2026-07-13 13:36:38 +08:00

41 lines
1.1 KiB
Python

from __future__ import annotations
from pathlib import Path
import pytest
from pytest_examples import CodeExample, EvalExample
def pytest_addoption(parser: pytest.Parser) -> None:
group = parser.getgroup("docs")
group.addoption(
"--run-doc-examples",
action="store_true",
help="Execute doc code examples (requires network access and API keys).",
)
@pytest.fixture(name="eval_example")
def eval_example(
tmp_path: Path,
request: pytest.FixtureRequest,
_examples_to_update: list[CodeExample],
):
eval_ex = EvalExample(tmp_path=tmp_path, pytest_request=request)
run_live = bool(
request.config.getoption("run_doc_examples", default=False)
or request.config.getoption("update_examples", default=False)
)
if not run_live:
def _skip_run(_example: CodeExample) -> None:
return None
eval_ex.run = _skip_run # type: ignore[assignment]
eval_ex.run_print_update = _skip_run # type: ignore[assignment]
yield eval_ex
if request.config.getoption("update_examples", default=False):
_examples_to_update.extend(eval_ex.to_update)