Option C Tools
Loading...
Searching...
No Matches
tests_core.test_parsing Namespace Reference

Functions

list[str] _lines (str text)
 test_full_header_boundary_is_four ()
 test_missing_shebang_skips_to_encoding ()
 test_no_header_returns_zero ()
 test_trailing_blank_not_consumed_without_header ()
 test_identity_fallback_matches_basename ()
 test_safe_parse_returns_none_on_syntax_error ()
 test_safe_parse_captures_invalid_escape_warning ()

Detailed Description

Purpose
-------
OI-509 / FS-505 regression tests — :func:`oct.core.parsing.header_boundary`
is the single implementation shared by the linter and the formatter for
locating the start of file content after an Option-C 4-line header
(shebang → encoding → file-identity → blank).

Also covers :func:`oct.core.parsing.safe_parse` — shared AST helper that
captures ``SyntaxWarning`` diagnostics instead of leaking them to stderr.

Responsibilities
----------------
- Full 4-line header → boundary is 4.
- Missing shebang → skips straight to encoding.
- No header at all → boundary is 0.
- Trailing blank is only consumed when at least one header element matched.
- Identity comment is matched via either the strict expected string or the
  path-basename fallback.
- ``safe_parse`` returns (None, []) on syntax error.
- ``safe_parse`` captures invalid-escape SyntaxWarnings without printing.

Diagnostics
-----------
Domain: CORE-TESTS
Levels:
    L2 — test lifecycle
    L3 — assertion details
    L4 — deep tracing

Contracts
---------
- Tests operate on in-memory strings; no files are created or read.

Function Documentation

◆ _lines()

list[str] tests_core.test_parsing._lines ( str text)
protected

Definition at line 45 of file test_parsing.py.

Here is the caller graph for this function:

◆ test_full_header_boundary_is_four()

tests_core.test_parsing.test_full_header_boundary_is_four ( )

Definition at line 49 of file test_parsing.py.

Here is the call graph for this function:

◆ test_identity_fallback_matches_basename()

tests_core.test_parsing.test_identity_fallback_matches_basename ( )
When no expected_identity is passed, any `# ...basename` qualifies.

Definition at line 88 of file test_parsing.py.

Here is the call graph for this function:

◆ test_missing_shebang_skips_to_encoding()

tests_core.test_parsing.test_missing_shebang_skips_to_encoding ( )

Definition at line 63 of file test_parsing.py.

Here is the call graph for this function:

◆ test_no_header_returns_zero()

tests_core.test_parsing.test_no_header_returns_zero ( )

Definition at line 76 of file test_parsing.py.

Here is the call graph for this function:

◆ test_safe_parse_captures_invalid_escape_warning()

tests_core.test_parsing.test_safe_parse_captures_invalid_escape_warning ( )

Definition at line 106 of file test_parsing.py.

◆ test_safe_parse_returns_none_on_syntax_error()

tests_core.test_parsing.test_safe_parse_returns_none_on_syntax_error ( )

Definition at line 100 of file test_parsing.py.

◆ test_trailing_blank_not_consumed_without_header()

tests_core.test_parsing.test_trailing_blank_not_consumed_without_header ( )

Definition at line 82 of file test_parsing.py.

Here is the call graph for this function: