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

Functions

str _make_nontrivial (str content)
 test_add_missing_import (Path temp_project_root, FormatterContext formatter_ctx_fix)
 test_skip_trivial_files (Path temp_project_root, FormatterContext formatter_ctx_fix)
 test_import_dry_run (Path temp_project_root, FormatterContext formatter_ctx)
 test_canonical_import_no_change (Path temp_project_root, FormatterContext formatter_ctx_fix)
 test_preserve_other_imports (Path temp_project_root, FormatterContext formatter_ctx_fix)

Detailed Description

Tests for import fixing.

Purpose
-------
Verify that the formatter correctly fixes _dbg import issues.

Responsibilities
----------------
- Test addition of canonical _dbg import when missing.
- Test removal of aliased/incorrect imports.
- Test correct placement after header block.
- Test preservation of other imports.

Diagnostics
-----------
Domain: TESTS.FORMATTER
Levels:
    L2 — test lifecycle
    L3 — test case setup
    L4 — detailed import parsing and verification

Contracts
---------
- Canonical form is: from oc_diagnostics import _dbg
- Import must be at module level (after header block).
- Trivial files (< 20 lines) are skipped.
- Other imports are preserved.

Function Documentation

◆ _make_nontrivial()

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

Definition at line 42 of file test_import_fixing.py.

Here is the caller graph for this function:

◆ test_add_missing_import()

tests_formatter.test_import_fixing.test_add_missing_import ( Path temp_project_root,
FormatterContext formatter_ctx_fix )
Test that canonical import is added when missing.

Definition at line 50 of file test_import_fixing.py.

Here is the call graph for this function:

◆ test_canonical_import_no_change()

tests_formatter.test_import_fixing.test_canonical_import_no_change ( Path temp_project_root,
FormatterContext formatter_ctx_fix )
Test that canonical imports are not modified.

Definition at line 99 of file test_import_fixing.py.

Here is the call graph for this function:

◆ test_import_dry_run()

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

Definition at line 80 of file test_import_fixing.py.

Here is the call graph for this function:

◆ test_preserve_other_imports()

tests_formatter.test_import_fixing.test_preserve_other_imports ( Path temp_project_root,
FormatterContext formatter_ctx_fix )
Test that other imports are preserved.

Definition at line 119 of file test_import_fixing.py.

Here is the call graph for this function:

◆ test_skip_trivial_files()

tests_formatter.test_import_fixing.test_skip_trivial_files ( Path temp_project_root,
FormatterContext formatter_ctx_fix )
Test that trivial files (< 20 lines) are skipped.

Definition at line 69 of file test_import_fixing.py.