Option C Tools
Loading...
Searching...
No Matches
tests_formatter.test_header_fixing Namespace Reference

Functions

 test_fix_missing_shebang (Path temp_project_root, FormatterContext formatter_ctx_fix)
 test_fix_missing_encoding (Path temp_project_root, FormatterContext formatter_ctx_fix)
 test_fix_wrong_path_header (Path temp_project_root, FormatterContext formatter_ctx_fix)
 test_header_archives_original (Path temp_project_root, FormatterContext formatter_ctx_fix)
 test_header_preserves_code (Path temp_project_root, FormatterContext formatter_ctx_fix)
 test_header_dry_run_no_modify (Path temp_project_root, FormatterContext formatter_ctx)
 test_header_correct_no_change (Path temp_project_root, FormatterContext formatter_ctx_fix)

Detailed Description

Tests for header block fixing.

Purpose
-------
Verify that the formatter correctly fixes malformed header blocks.

Responsibilities
----------------
- Test missing shebang fixes.
- Test missing encoding fixes.
- Test incorrect file identity fixes.
- Test missing blank line fixes.
- Verify archival of original files.
- Verify code preservation.

Diagnostics
-----------
Domain: TESTS.FORMATTER
Levels:
    L2 — test lifecycle
    L3 — test case setup
    L4 — detailed assertion checks

Contracts
---------
- All tests verify that fix_header_block returns (True, new_text, messages) when changes are needed.
- All tests verify that original files are archived before modification.

Function Documentation

◆ test_fix_missing_encoding()

tests_formatter.test_header_fixing.test_fix_missing_encoding ( Path temp_project_root,
FormatterContext formatter_ctx_fix )
Test that missing encoding is added correctly.

Definition at line 59 of file test_header_fixing.py.

◆ test_fix_missing_shebang()

tests_formatter.test_header_fixing.test_fix_missing_shebang ( Path temp_project_root,
FormatterContext formatter_ctx_fix )
Test that missing shebang is added correctly.

Definition at line 41 of file test_header_fixing.py.

◆ test_fix_wrong_path_header()

tests_formatter.test_header_fixing.test_fix_wrong_path_header ( Path temp_project_root,
FormatterContext formatter_ctx_fix )
Test that incorrect file path header is rewritten.

Definition at line 77 of file test_header_fixing.py.

◆ test_header_archives_original()

tests_formatter.test_header_fixing.test_header_archives_original ( Path temp_project_root,
FormatterContext formatter_ctx_fix )
Test that format_file archives original before writing (archival moved to format_file).

Definition at line 96 of file test_header_fixing.py.

◆ test_header_correct_no_change()

tests_formatter.test_header_fixing.test_header_correct_no_change ( Path temp_project_root,
FormatterContext formatter_ctx_fix )
Test that correct headers are not modified.

Definition at line 152 of file test_header_fixing.py.

◆ test_header_dry_run_no_modify()

tests_formatter.test_header_fixing.test_header_dry_run_no_modify ( Path temp_project_root,
FormatterContext formatter_ctx )
Test that dry-run mode doesn't modify files.

Definition at line 140 of file test_header_fixing.py.

◆ test_header_preserves_code()

tests_formatter.test_header_fixing.test_header_preserves_code ( Path temp_project_root,
FormatterContext formatter_ctx_fix )
Test that code below header is preserved exactly.

Definition at line 116 of file test_header_fixing.py.