Check that every test function asserts something

Đang mở
#4,187 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 2 ngày

@anth-volk đang làm issue này rồi.

Từ ngày 4/11/2026.

  • #4188 của @anth-volk — đang mở

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
testing

Hướng nghiên cứu

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.

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

Mô tả

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.

Ngôn ngữ chính
Python
Star
18
Fork
33
Merge trung bình
2 ngày 21 giờ
Pull request đã merge (30 ngày)
93

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

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 PolicyEngine/policyengine-api

Tất cả issue của PolicyEngine/policyengine-api

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.