52 Run the linter in --fix-headers mode and ensure the fix is applied.
54 oct_lint.run_linter(temp_project_root, argv=[
"--fix-headers"])
57 fixture = temp_project_root /
"tests_linter" /
"fixtures" /
"minimal_valid.py"
58 text = fixture.read_text(encoding=
"utf-8")
59 lines = text.splitlines()
61 ok, errors = oct_lint.validate_header_block(lines, fixture, linter_ctx)
62 assert ok, f
"Header block should validate after fix mode, errors: {errors}"
67 Run the linter in --json mode and verify the output is valid JSON with
68 the expected top-level structure.
70 captured = io.StringIO()
71 original_stdout = sys.stdout
74 oct_lint.run_linter(temp_project_root, argv=[
"--json"])
76 sys.stdout = original_stdout
78 output = captured.getvalue().strip()
79 assert output,
"Expected JSON output on stdout"
81 data = json.loads(output)
83 assert "project" in data
84 assert "oct_version" in data
85 assert "timestamp" in data
86 assert "summary" in data
87 assert "files" in data
89 summary = data[
"summary"]
90 for key
in (
"total_files",
"fully_compliant",
"pass_header",
"pass_docstring",
91 "pass_diagnostics_profile",
"pass_dbg",
"pass_func",
"pass_tests"):
94 assert isinstance(data[
"files"], list)
95 for file_entry
in data[
"files"]:
96 assert "path" in file_entry
97 assert "checks" in file_entry
98 assert "compliant" in file_entry
99 for key
in (
"header",
"docstring",
"diagnostics_profile",
"dbg_usage",
"func_pattern",
"tests_exist"):
100 assert key
in file_entry[
"checks"]
101 assert "pass" in file_entry[
"checks"][key]
102 assert "message" in file_entry[
"checks"][key]