From e2ee9b51b1f7eea753f8aa16557a4bbe0e3a1f45 Mon Sep 17 00:00:00 2001 From: Guo Cheng <224264187+GuoCheng24@users.noreply.github.com> Date: Wed, 2 Sep 2026 08:50:06 +0800 Subject: [PATCH] Do not abort test collection when pexpect is missing tests/test_tui_e2e.py imports pexpect at module level, before the skipif mark below it. pexpect is not declared in pyproject.toml, install.sh or uv.lock, so on a clean checkout the 'pytest' command in CONTRIBUTING.md fails collection of the whole suite instead of skipping this one file. Use importorskip and declare the test-only dependencies in a dev extra. --- pyproject.toml | 1 + tests/test_tui_e2e.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index d8ac023f..8b8bfd95 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -25,6 +25,7 @@ dependencies = [ ] [project.optional-dependencies] +dev = ["pytest", "pexpect"] acp = [ "agent-client-protocol>=0.8,<1", ] diff --git a/tests/test_tui_e2e.py b/tests/test_tui_e2e.py index 443defcc..eaa82441 100644 --- a/tests/test_tui_e2e.py +++ b/tests/test_tui_e2e.py @@ -15,9 +15,14 @@ from pathlib import Path from typing import Any, Callable -import pexpect import pytest +# Imported lazily: pexpect is only needed by these TUI end-to-end tests. +# A module-level `import pexpect` runs before the skipif mark below, so on an +# install without it pytest aborts collection of the whole suite instead of +# skipping this one file. +pexpect = pytest.importorskip("pexpect") + ROOT = Path(__file__).resolve().parents[1] pytestmark = pytest.mark.skipif(shutil.which("script") is None, reason="`script` is required for TUI e2e tests")