Graph-check unit tests fail under direct pytest because logger fixtures assume Bazel runfiles

Đang mở Phù hợp với người mới
#999 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

Chưa có ai nhận issue này.

  • #1000 của @AlexanderLanin — đã đóng, không merge

Đá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
78/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
testing

Hướng nghiên cứu

Bắt đầu bằng cách chạy .venv_docs/bin/python -m pytest src/extensions/score_metamodel/tests/test_graph_checks.py -q với RUNFILES_DIR và RUNFILES_MANIFEST_FILE chưa được đặt để tái hiện sáu lỗi. Đọc fake_check_logger() trong src/extensions/score_metamodel/tests/__init__.py và CheckLogger._location() trong src/extensions/score_metamodel/log.py; fixture cung cấp một tiền tố đường dẫn MagicMock mà các vị trí không thuộc Bazel tiết lộ. Hoàn thành nghĩa là cả sáu assertion về vị trí đều đạt dưới pytest trực tiếp trong khi bazel test //src/extensions/score_metamodel:unit_tests vẫn đạt.

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

Mô tả

bug

Graph-check unit tests fail when invoked directly through pytest, although the Bazel unit-test target passes. Developers should be able to run these tests through pytest, including from an IDE, without a Bazel runfiles environment.

Reproduction

Reproduced on a clean snapshot of main at 946fd135045841db63e18ffd532374963e84a220, using Python 3.12.12 and pytest 9.1.1.

After preparing the development environment:

bazel run //:ide_support
.venv_docs/bin/python -m pytest src/extensions/score_metamodel/tests/test_graph_checks.py -q

Run from a normal shell with RUNFILES_DIR and RUNFILES_MANIFEST_FILE unset.

Actual result

6 failed, 17 passed:

  • test_eval_need_check_missing_attribute_logs_and_returns_false
  • test_check_all_warns_once_per_failing_parent
  • test_check_one[none_fulfill]
  • test_check_one[no_parents]
  • test_check_one[unknown_parent]
  • test_info_only_keeps_message

The failures are location assertions. For example:

Expected: docname.rst:42
Actual:   <MagicMock id='...'>/docname.rst:42

For comparison, the normal Bazel invocation passes all 109 tests:

bazel test //src/extensions/score_metamodel:unit_tests
Cause

fake_check_logger() passes a MagicMock as the logger's path prefix, while its assertions expect docname.rst:42.

CheckLogger._location() omits that prefix in a Bazel runfiles environment. Outside Bazel, it includes the prefix, exposing the mock in the location string and causing the assertions to fail.

Expected result
  • The graph-check unit tests pass through both direct pytest and Bazel invocations.
  • Logger fixtures and location assertions work without externally supplied Bazel runfiles variables, while retaining meaningful verification of diagnostic locations.
Ngôn ngữ chính
Python
Star
11
Fork
37
Merge trung bình
1 ngày 1 giờ
Pull request đã merge (30 ngày)
61

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.

  • Không có Dockerfile hay tệp Docker Compose
  • Có mẫu pull request
  • Không có hướng dẫn đóng góp

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 eclipse-score/docs-as-code

Tất cả issue của eclipse-score/docs-as-code

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.