From 845da9c938babde78b6cb5ea67d19af005ed3b26 Mon Sep 17 00:00:00 2001 From: S S Sushant Marin Date: Mon, 17 Aug 2026 16:09:35 +0530 Subject: [PATCH] Surface pytest output in CI and drop unused asyncio plugin. The test matrix still fails in seconds after python -m pytest; write the log to the job summary so the real error is visible, and stop depending on pytest-asyncio since no tests are async. Co-authored-by: Cursor --- .github/workflows/ci.yml | 23 +++++++++++++++++++---- pyproject.toml | 5 +---- tests/test_agent_runner.py | 8 +++++--- tests/test_cli.py | 7 ++++--- tests/test_fixtures.py | 3 ++- tests/test_gemini_history.py | 36 ++++++++++++++++++++---------------- tests/test_http_utils.py | 4 +++- 7 files changed, 54 insertions(+), 32 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f49f8b5..206fa6a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: - uses: actions/setup-python@v5 with: python-version: "3.12" - - run: pip install -e ".[dev]" + - run: python -m pip install -e ".[dev]" - run: ruff check skilldiff tests examples fixtures - run: ruff format --check skilldiff tests examples fixtures - run: mypy @@ -32,6 +32,21 @@ jobs: - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} - - run: pip install -e ".[dev]" - - run: python -m pytest -v --tb=short - - run: skilldiff demo + - run: python -m pip install -e ".[dev]" + - name: Run pytest + run: | + set +e + python -m pytest -vv --tb=short | tee pytest.log + status=${PIPESTATUS[0]} + { + echo "## Pytest (Python ${{ matrix.python-version }})" + echo + echo '```' + cat pytest.log + echo '```' + } >> "$GITHUB_STEP_SUMMARY" + if [ "$status" -ne 0 ]; then + python -c 'from pathlib import Path; text=Path("pytest.log").read_text(errors="replace")[-4000:]; print("::error title=pytest failed::" + text.replace("%", "%25").replace("\r", "%0D").replace("\n", "%0A"))' + fi + exit "$status" + - run: python -m skilldiff demo diff --git a/pyproject.toml b/pyproject.toml index 966850d..121a224 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -45,7 +45,6 @@ Changelog = "https://github.com/shunvel/skilldiff/blob/main/CHANGELOG.md" [project.optional-dependencies] dev = [ "pytest>=7.0", - "pytest-asyncio>=0.23", "ruff>=0.6", "mypy>=1.8", ] @@ -55,9 +54,7 @@ packages = ["skilldiff"] [tool.pytest.ini_options] testpaths = ["tests"] -asyncio_mode = "auto" -asyncio_default_fixture_loop_scope = "function" -addopts = "-q --tb=short" +addopts = "--tb=short" pythonpath = ["."] [tool.ruff] diff --git a/tests/test_agent_runner.py b/tests/test_agent_runner.py index 57f04e0..333a9ee 100644 --- a/tests/test_agent_runner.py +++ b/tests/test_agent_runner.py @@ -6,22 +6,24 @@ from skilldiff.tools_schema import build_tool_specs, load_tools_from_script +REPO_ROOT = Path(__file__).resolve().parents[1] + def test_load_baseline_tools_from_examples() -> None: - tools = load_tools_from_script(Path("examples/baseline_tools.py")) + tools = load_tools_from_script(REPO_ROOT / "examples/baseline_tools.py") assert "fetch_url" in tools assert "read_text_file" in tools assert "_fetch_url" not in tools def test_load_variant_tools_from_examples() -> None: - tools = load_tools_from_script(Path("examples/variant_tools.py")) + tools = load_tools_from_script(REPO_ROOT / "examples/variant_tools.py") assert "fetch_and_extract_title" in tools assert "summarize_text" in tools def test_build_function_declarations_has_parameters() -> None: - tools = load_tools_from_script(Path("examples/baseline_tools.py")) + tools = load_tools_from_script(REPO_ROOT / "examples/baseline_tools.py") declarations = build_tool_specs(tools) names = {decl.name for decl in declarations} assert "fetch_url" in names diff --git a/tests/test_cli.py b/tests/test_cli.py index a4cdcf0..a3c73d7 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -14,9 +14,10 @@ def test_demo_exits_zero_and_writes_json(tmp_path: Path, monkeypatch) -> None: monkeypatch.chdir(tmp_path) result = runner.invoke(app, ["demo", "--output-dir", ".agent_diff"]) - assert result.exit_code == 0, result.output - assert "skilldiff Results" in result.output - assert "Win Rate" in result.output + combined = f"{result.output}\n{result.stdout}\n{getattr(result, 'stderr', '')}" + assert result.exit_code == 0, combined + assert "skilldiff Results" in combined + assert "Win Rate" in combined output_dir = tmp_path / ".agent_diff" files = list(output_dir.glob("results_*.json")) diff --git a/tests/test_fixtures.py b/tests/test_fixtures.py index e2959b5..b3a7d6c 100644 --- a/tests/test_fixtures.py +++ b/tests/test_fixtures.py @@ -6,7 +6,8 @@ from skilldiff.models import Task from skilldiff.tools_schema import load_tools_from_script -FIXTURE = Path("fixtures/demo-repo") +REPO_ROOT = Path(__file__).resolve().parents[1] +FIXTURE = REPO_ROOT / "fixtures/demo-repo" def test_fixture_tasks_cover_sanity_and_eval() -> None: diff --git a/tests/test_gemini_history.py b/tests/test_gemini_history.py index 290fb46..f0a50dd 100644 --- a/tests/test_gemini_history.py +++ b/tests/test_gemini_history.py @@ -1,19 +1,27 @@ """Tests for Gemini thought_signature history preservation.""" +import pytest from google.genai import types from skilldiff.llm import AgentTurn, ToolCall, _messages_to_gemini_contents, append_assistant_message +def _model_content(*, name: str, args: dict, signature: bytes) -> types.Content: + try: + part = types.Part( + function_call=types.FunctionCall(name=name, args=args), + thought_signature=signature, + ) + except (TypeError, ValueError) as exc: + pytest.skip(f"google-genai Part() rejected thought_signature: {exc}") + return types.Content(role="model", parts=[part]) + + def test_append_assistant_message_preserves_gemini_model_content() -> None: - model_content = types.Content( - role="model", - parts=[ - types.Part( - function_call=types.FunctionCall(name="fetch_url", args={"url": "https://x.com"}), - thought_signature=b"sig-bytes", - ) - ], + model_content = _model_content( + name="fetch_url", + args={"url": "https://x.com"}, + signature=b"sig-bytes", ) turn = AgentTurn( text="", @@ -28,14 +36,10 @@ def test_append_assistant_message_preserves_gemini_model_content() -> None: def test_messages_to_gemini_contents_replays_raw_model_content() -> None: - model_content = types.Content( - role="model", - parts=[ - types.Part( - function_call=types.FunctionCall(name="read_text_file", args={"path": "a.txt"}), - thought_signature=b"keep-me", - ) - ], + model_content = _model_content( + name="read_text_file", + args={"path": "a.txt"}, + signature=b"keep-me", ) contents = _messages_to_gemini_contents( [ diff --git a/tests/test_http_utils.py b/tests/test_http_utils.py index 1ed850d..8af4ea8 100644 --- a/tests/test_http_utils.py +++ b/tests/test_http_utils.py @@ -6,9 +6,11 @@ from skilldiff.tools_schema import load_tools_from_script +REPO_ROOT = Path(__file__).resolve().parents[1] + def test_fetch_url_text_uses_certifi_context() -> None: - tools = load_tools_from_script(Path("examples/http_utils.py")) + tools = load_tools_from_script(REPO_ROOT / "examples/http_utils.py") fetch_url_text = tools["fetch_url_text"] module = sys.modules[fetch_url_text.__module__]