Coverage for tests / unit / parsers / pydoclint_parser / conftest.py: 100%
12 statements
« prev ^ index » next coverage.py v7.13.0, created at 2026-04-03 18:53 +0000
« prev ^ index » next coverage.py v7.13.0, created at 2026-04-03 18:53 +0000
1"""Shared fixtures and utilities for pydoclint parser tests."""
3from __future__ import annotations
6def make_pydoclint_output(issues: list[tuple[str, int, int, str, str]]) -> str:
7 """Create pydoclint output string from a list of issue tuples.
9 Pydoclint output format:
10 /path/to/file.py
11 10: DOC101: message
13 Args:
14 issues: List of tuples (file, line, col, code, message).
15 Note: col is ignored as pydoclint doesn't report column info.
17 Returns:
18 Formatted pydoclint output string.
19 """
20 lines: list[str] = []
21 current_file: str | None = None
23 for file_path, line, _col, code, message in issues:
24 # Add file path line if it's a new file
25 if file_path != current_file:
26 current_file = file_path
27 lines.append(file_path)
28 # Add indented issue line
29 lines.append(f" {line}: {code}: {message}")
31 return "\n".join(lines)
34def make_issue(
35 *,
36 file: str = "test.py",
37 line: int = 10,
38 column: int = 5,
39 code: str = "DOC101",
40 message: str = "Test message",
41) -> tuple[str, int, int, str, str]:
42 """Create a pydoclint issue tuple with sensible defaults.
44 Args:
45 file: The file path.
46 line: The line number.
47 column: The column number.
48 code: The error code.
49 message: The error message.
51 Returns:
52 Tuple representing a pydoclint issue.
53 """
54 return (file, line, column, code, message)