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

オープン 初心者向け
#999 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

  • #1000 @AlexanderLanin による — マージされずにクローズ

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
python
領域
testing

調査の方向性

まず .venv_docs/bin/python -m pytest src/extensions/score_metamodel/tests/test_graph_checks.py -q を、RUNFILES_DIR と RUNFILES_MANIFEST_FILE を未設定のまま実行して、6 件の失敗を再現してください。src/extensions/score_metamodel/tests/__init__.py の fake_check_logger() と src/extensions/score_metamodel/log.py の CheckLogger._location() を読んでください。fixture は、非 Bazel の location が公開する MagicMock のパスプレフィックスを提供します。完了とは、直接 pytest を実行したときに 6 件すべての location assertion が通り、かつ bazel test //src/extensions/score_metamodel:unit_tests も引き続き通ることを意味します。

索引モデルが issue の本文から書いたものです。

説明

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.
主要言語
Python
スター
11
フォーク
37
平均マージ
1日 1時間
マージ済み PR(30日)
61

環境構築

Codespaces で開く

このプロジェクトの開発コンテナを、あなたの GitHub アカウントでブラウザ上に起動します。

  • Dockerfile・Docker Compose ファイルなし
  • プルリクエストのテンプレートあり
  • コントリビューションガイドなし

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

eclipse-score/docs-as-code のほかの issue

eclipse-score/docs-as-code の issue をすべて見る

似ている issue

Python の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。