Parity tests fail under the documented direct pytest invocation when the ambient python3 lacks PyYAML (11 failures)

Đang mở Phù hợp với người mới
#5,359 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

@mehdikarimi55 đang làm issue này rồi.

Từ ngày 10/11/2026.

  • #5361 của @mehdikarimi55 — đang mở

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
devtools, testing

Hướng nghiên cứu

Đọc tests/parity_helpers.py và so sánh cách clean_env() hoạt động với _clean_env() cục bộ trong tests/test_check_prerequisites_python_parity.py. Trước tiên, hãy kiểm tra cách các helper này thiết lập PATH và cách các bài kiểm tra shim không có YAML giữ nguyên thứ tự ưu tiên. Hoàn tất khi lệnh gọi pytest trực tiếp sử dụng trình thông dịch của bộ kiểm thử cho các tiến trình con và các bài kiểm tra tương thích bị ảnh hưởng đều đạt.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

triage-must-have

Summary

Following AGENTS.md's prescribed invocation — uv sync --extra test then .venv/bin/python -m pytest — 11 parity tests fail on a fresh macOS checkout whose ambient python3 does not have PyYAML installed (e.g. Homebrew Python):

FAILED tests/test_check_prerequisites_python_parity.py::test_all_variants_resolve_requested_template[composed]
FAILED tests/test_check_prerequisites_python_parity.py::test_all_variants_validate_requested_template_in_text_mode[composed]
FAILED tests/test_create_new_feature_python_parity.py::test_all_variants_materialize_composed_spec_template
FAILED tests/test_resolve_template_python_parity.py (7 tests, all [composed]-style)
FAILED tests/test_setup_plan_python_parity.py::test_all_variants_materialize_composed_plan_template
FAILED tests/test_setup_tasks_python_parity.py::test_all_variants_return_composed_tasks_template

Each failure is the bash variant reporting Error: PyYAML is required to resolve preset template composition.

Root cause

run() in tests/parity_helpers.py defaults to clean_env(), which is a copy of os.environ — the script subprocesses resolve python3 -> python -> py -3 through the ambient PATH.

  • In CI, tests run via uv run pytest, and uv run prepends the project venv's bin/ to PATH, so the scripts find the venv interpreter (which has PyYAML) and everything passes.
  • Under the direct .venv/bin/python -m pytest invocation documented in AGENTS.md, PATH is untouched, so the scripts find the ambient python3 (no PyYAML) and fail.

tests/parity_helpers.py already contains make_python3_path_shim() whose docstring warns about exactly this hazard ("silently regains/loses that venv's site-packages (e.g. PyYAML)"), and tests/extensions/test_extension_agent_context.py contains a similar _ensure_test_python_on_path() helper — the composed-template tests just don't get the same treatment.

Suggested fix

Prepend the running interpreter's own bin directory to PATH inside parity_helpers.clean_env() — the same thing uv run does — so both invocations give the script subprocesses the same Python the suite runs on. Tests that install their own shim (the no_yaml_python3_shim cases) prepend afterwards and keep precedence, so the negative tests are unaffected. One tests/test_check_prerequisites_python_parity.py defines a file-local _clean_env() duplicate and needs the same treatment (delegate to the shared helper).

Reproduction

git clone https://github.com/github/spec-kit && cd spec-kit
uv sync --extra test          # or: python -m venv .venv && pip install -e . pytest
# ensure the ambient `python3` has no PyYAML:
python3 -c "import yaml" || echo "ambient python3 has no PyYAML"
.venv/bin/python -m pytest tests/test_resolve_template_python_parity.py -q   # 7 failed
PATH="$PWD/.venv/bin:$PATH" .venv/bin/python -m pytest tests/test_resolve_template_python_parity.py -q   # all pass

Observed on macOS 15 (Apple Silicon), Python 3.12, spec-kit main at 08252af.

AI disclosure

Issue filed after diagnosis performed with AI assistance: OpenCode running GLM 5.3 Flash (Z.ai), agent mode under human supervision by @mehdikarimi55; environment reproduction, root-cause analysis, and verification of the PATH-based fix.

Ngôn ngữ chính
Python
Star
149k
Fork
13.4k
Merge trung bình
1 ngày 5 giờ
Pull request đã merge (30 ngày)
223

Chuẩn bị môi trường

Mở trong Codespaces

Khởi chạy dev container của dự án ngay trên trình duyệt, bằng tài khoản GitHub của bạn.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của github/spec-kit

Tất cả issue của github/spec-kit

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.