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

Functions

str _make_nontrivial (str content)
 test_add_func_pattern_single_function (Path temp_project_root, FormatterContext formatter_ctx_fix)
 test_add_func_pattern_multiple_functions (Path temp_project_root, FormatterContext formatter_ctx_fix)
 test_skip_function_without_dbg (Path temp_project_root, FormatterContext formatter_ctx_fix)
 test_skip_existing_pattern (Path temp_project_root, FormatterContext formatter_ctx_fix)
 test_skip_trivial_files (Path temp_project_root, FormatterContext formatter_ctx_fix)
 test_detect_indent_style_tabs_dominant ()
 test_detect_indent_style_spaces_dominant ()
 test_detect_indent_style_ignores_blank_lines ()
None test_fix_func_pattern_preserves_tabs (Path temp_project_root, FormatterContext formatter_ctx_fix)
None test_fix_func_pattern_preserves_spaces (Path temp_project_root, FormatterContext formatter_ctx_fix)
None test_fix_func_pattern_tab_indented_class_method (Path temp_project_root, FormatterContext formatter_ctx_fix)

Detailed Description

Tests for func pattern fixing.

Purpose
-------
Verify that the formatter correctly fixes missing func = "..." patterns.

Responsibilities
----------------
- Test addition of func variable to functions with _dbg() calls.
- Test skipping of functions without _dbg() calls.
- Test skipping of functions that already have the pattern.
- Test proper indentation.

Diagnostics
-----------
Domain: TESTS.FORMATTER
Levels:
    L2 — test lifecycle
    L3 — test case setup
    L4 — AST parsing and pattern insertion

Contracts
---------
- func variable must be first statement in function.
- Pattern is skipped if already present.
- Functions without _dbg() are never modified.

Function Documentation

◆ _make_nontrivial()

str tests_formatter.test_func_pattern_fixing._make_nontrivial ( str content)
protected
Pad content to be > 20 lines.

Definition at line 45 of file test_func_pattern_fixing.py.

Here is the caller graph for this function:

◆ test_add_func_pattern_multiple_functions()

tests_formatter.test_func_pattern_fixing.test_add_func_pattern_multiple_functions ( Path temp_project_root,
FormatterContext formatter_ctx_fix )
Test adding func pattern to multiple functions.

Definition at line 75 of file test_func_pattern_fixing.py.

Here is the call graph for this function:

◆ test_add_func_pattern_single_function()

tests_formatter.test_func_pattern_fixing.test_add_func_pattern_single_function ( Path temp_project_root,
FormatterContext formatter_ctx_fix )
Test adding func pattern to a single function.

Definition at line 53 of file test_func_pattern_fixing.py.

Here is the call graph for this function:

◆ test_detect_indent_style_ignores_blank_lines()

tests_formatter.test_func_pattern_fixing.test_detect_indent_style_ignores_blank_lines ( )
Blank lines must not affect the tally.

Definition at line 189 of file test_func_pattern_fixing.py.

◆ test_detect_indent_style_spaces_dominant()

tests_formatter.test_func_pattern_fixing.test_detect_indent_style_spaces_dominant ( )
``_detect_indent_style`` returns '    ' when spaces dominate.

Definition at line 178 of file test_func_pattern_fixing.py.

◆ test_detect_indent_style_tabs_dominant()

tests_formatter.test_func_pattern_fixing.test_detect_indent_style_tabs_dominant ( )
``_detect_indent_style`` returns '\\t' when tabs dominate.

Definition at line 166 of file test_func_pattern_fixing.py.

◆ test_fix_func_pattern_preserves_spaces()

None tests_formatter.test_func_pattern_fixing.test_fix_func_pattern_preserves_spaces ( Path temp_project_root,
FormatterContext formatter_ctx_fix )
Baseline: a space-indented file still receives space injection.

Definition at line 225 of file test_func_pattern_fixing.py.

Here is the call graph for this function:

◆ test_fix_func_pattern_preserves_tabs()

None tests_formatter.test_func_pattern_fixing.test_fix_func_pattern_preserves_tabs ( Path temp_project_root,
FormatterContext formatter_ctx_fix )
A tab-indented file receives a tab-indented ``func = "..."`` line.

Definition at line 195 of file test_func_pattern_fixing.py.

Here is the call graph for this function:

◆ test_fix_func_pattern_tab_indented_class_method()

None tests_formatter.test_func_pattern_fixing.test_fix_func_pattern_tab_indented_class_method ( Path temp_project_root,
FormatterContext formatter_ctx_fix )
A class method in a tab-indented file gets a ``\\t\\t`` injection.

Definition at line 252 of file test_func_pattern_fixing.py.

Here is the call graph for this function:

◆ test_skip_existing_pattern()

tests_formatter.test_func_pattern_fixing.test_skip_existing_pattern ( Path temp_project_root,
FormatterContext formatter_ctx_fix )
Test that existing func patterns are not duplicated.

Definition at line 126 of file test_func_pattern_fixing.py.

Here is the call graph for this function:

◆ test_skip_function_without_dbg()

tests_formatter.test_func_pattern_fixing.test_skip_function_without_dbg ( Path temp_project_root,
FormatterContext formatter_ctx_fix )
Test that functions without _dbg() are not modified.

Definition at line 100 of file test_func_pattern_fixing.py.

Here is the call graph for this function:

◆ test_skip_trivial_files()

tests_formatter.test_func_pattern_fixing.test_skip_trivial_files ( Path temp_project_root,
FormatterContext formatter_ctx_fix )
Test that trivial files are skipped.

Definition at line 147 of file test_func_pattern_fixing.py.