Check that every test function asserts something

オープン
#4,187 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

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

@anth-volk がすでに取り組んでいます。

2026年11月4日 から。

  • #4188 @anth-volk による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
機能追加
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
python
領域
testing

調査の方向性

Read step 2.7 of the code-quality plan and inspect rules/registry.toml for how ratcheted rules are registered. Then review existing rule implementations, tests under scripts/rules/tests/, and the 22 baseline cases described in the issue. Done means the rule detects the listed assertion forms and helper calls, records current exceptions in a baseline under rules/baselines/, and the baseline can only shrink; pull request #4188 is already open.

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

説明

What

Add a quality guard that fails on any test function that checks nothing: one that contains no assert, no pytest.raises (or pytest.warns, pytest.fail), no unittest self.assert... or self.fail, no mock assert_called... or other call to an assert... function, no raise AssertionError, and no call to a helper that does one of these. Today's tests that check nothing go in a baseline file under rules/baselines/, which can only shrink.

Why

A test without a check passes whatever the code returns, as long as nothing raises. Of the 3,013 test functions in tests/ and scripts/rules/tests/, 22 check nothing today, for example tests/unit/test_warmup.py::test_run_startup_warmup_swallows_calculate_errors. Most of these only show that a call doesn't raise. They pass even if the call returns the wrong value.

This is the "every test function asserts something" check in step 2.7 of the code-quality plan, registered in rules/registry.toml as a ratcheted rule.

主要言語
Python
スター
18
フォーク
33
平均マージ
2日 21時間
マージ済み PR(30日)
93

環境構築

はじめの一歩

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

PolicyEngine/policyengine-api のほかの issue

PolicyEngine/policyengine-api の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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