6Tests for lint health check.
10Verify that check_lint_health correctly aggregates linter results.
14- Test fully compliant projects.
15- Test partially compliant projects.
17- Test verbose mode file details.
24 L3 — lint aggregation verification
25 L4 — per-check count validation
29- Compliance percentage is calculated correctly.
30- Per-check pass counts match actual results.
31- Verbose mode includes per-file breakdown.
35from pathlib
import Path
39from tests.tests_health.conftest
import make_compliant_file, NON_COMPLIANT_FILE
43 """Test 100% compliance when all files pass."""
44 (temp_project_root /
"good.py").write_text(make_compliant_file(
"good.py"), encoding=
"utf-8")
46 result = check_lint_health(temp_project_root, linter_ctx)
48 assert result[
"total_files"] == 1
49 assert result[
"fully_compliant"] == 1
50 assert result[
"compliance_pct"] == 100.0
54 """Test mixed compliance results."""
55 (temp_project_root /
"good.py").write_text(make_compliant_file(
"good.py"), encoding=
"utf-8")
57 padded = NON_COMPLIANT_FILE +
"\n".join([
"# pad"] * 20)
58 (temp_project_root /
"bad.py").write_text(padded, encoding=
"utf-8")
60 result = check_lint_health(temp_project_root, linter_ctx)
62 assert result[
"total_files"] == 2
63 assert result[
"fully_compliant"] == 1
64 assert result[
"compliance_pct"] == 50.0
68 """Test health check on project with no Python files."""
69 result = check_lint_health(temp_project_root, linter_ctx)
71 assert result[
"total_files"] == 0
72 assert result[
"fully_compliant"] == 0
73 assert result[
"compliance_pct"] == 0.0
77 """Test that all check categories are reported."""
78 (temp_project_root /
"good.py").write_text(make_compliant_file(
"good.py"), encoding=
"utf-8")
80 result = check_lint_health(temp_project_root, linter_ctx)
82 expected_checks = [
"header",
"docstring",
"diagnostics_profile",
"dbg_usage",
"dbg_import",
"func_pattern"]
83 for check_name
in expected_checks:
84 assert check_name
in result[
"checks"]
85 assert "pass" in result[
"checks"][check_name]
86 assert "total" in result[
"checks"][check_name]
87 assert "pct" in result[
"checks"][check_name]
91 """Test that verbose mode includes per-file details."""
92 (temp_project_root /
"good.py").write_text(make_compliant_file(
"good.py"), encoding=
"utf-8")
94 result = check_lint_health(temp_project_root, linter_ctx, verbose=
True)
96 assert "files" in result
97 assert len(result[
"files"]) == 1
98 assert result[
"files"][0][
"compliant"]
is True
102 """Test that verbose mode shows failed checks per file."""
103 padded = NON_COMPLIANT_FILE +
"\n".join([
"# pad"] * 20)
104 (temp_project_root /
"bad.py").write_text(padded, encoding=
"utf-8")
106 result = check_lint_health(temp_project_root, linter_ctx, verbose=
True)
108 assert "files" in result
109 assert len(result[
"files"]) == 1
110 assert result[
"files"][0][
"compliant"]
is False
test_lint_health_verbose_includes_files(Path temp_project_root, LinterContext linter_ctx)
test_lint_health_empty_project(Path temp_project_root, LinterContext linter_ctx)
test_lint_health_partial_compliance(Path temp_project_root, LinterContext linter_ctx)
test_lint_health_all_compliant(Path temp_project_root, LinterContext linter_ctx)
test_lint_health_verbose_shows_failures(Path temp_project_root, LinterContext linter_ctx)
test_lint_health_check_categories(Path temp_project_root, LinterContext linter_ctx)