Coverage for tests / unit / conftest.py: 78%
37 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 for unit tests."""
3from typing import Any
5import pytest
8class FakeLogger:
9 """Minimal logger stub capturing method calls for assertions."""
11 def __init__(self) -> None:
12 """Initialize the fake logger with call storage and run dir."""
13 self.calls: list[tuple[str, tuple[Any, ...], dict[str, Any]]] = []
14 self.run_dir = ".lintro/test"
16 def _rec(self, name: str, *a: Any, **k: Any) -> None:
17 self.calls.append((name, a, k))
19 def info(self, *a: Any, **k: Any) -> None:
20 """Record an info call.
22 Args:
23 *a: Positional arguments passed to the logger.
24 **k: Keyword arguments passed to the logger.
25 """
26 self._rec("info", *a, **k)
28 def debug(self, *a: Any, **k: Any) -> None:
29 """Record a debug call.
31 Args:
32 *a: Positional arguments passed to the logger.
33 **k: Keyword arguments passed to the logger.
34 """
35 self._rec("debug", *a, **k)
37 def warning(self, *a: Any, **k: Any) -> None:
38 """Record a warning call.
40 Args:
41 *a: Positional arguments passed to the logger.
42 **k: Keyword arguments passed to the logger.
43 """
44 self._rec("warning", *a, **k)
46 def error(self, *a: Any, **k: Any) -> None:
47 """Record an error call.
49 Args:
50 *a: Positional arguments passed to the logger.
51 **k: Keyword arguments passed to the logger.
52 """
53 self._rec("error", *a, **k)
55 def success(self, *a: Any, **k: Any) -> None:
56 """Record a success call.
58 Args:
59 *a: Positional arguments passed to the logger.
60 **k: Keyword arguments passed to the logger.
61 """
62 self._rec("success", *a, **k)
64 def console_output(self, *a: Any, **k: Any) -> None:
65 """Record console output.
67 Args:
68 *a: Positional arguments passed to the logger.
69 **k: Keyword arguments passed to the logger.
70 """
71 self._rec("console_output", *a, **k)
73 def print_lintro_header(self, *a: Any, **k: Any) -> None:
74 """Record header printing.
76 Args:
77 *a: Positional arguments passed to the logger.
78 **k: Keyword arguments passed to the logger.
79 """
80 self._rec("print_lintro_header", *a, **k)
82 def print_verbose_info(self, *a: Any, **k: Any) -> None:
83 """Record verbose info printing.
85 Args:
86 *a: Positional arguments passed to the logger.
87 **k: Keyword arguments passed to the logger.
88 """
89 self._rec("print_verbose_info", *a, **k)
91 def print_tool_header(self, *a: Any, **k: Any) -> None:
92 """Record tool header printing.
94 Args:
95 *a: Positional arguments passed to the logger.
96 **k: Keyword arguments passed to the logger.
97 """
98 self._rec("print_tool_header", *a, **k)
100 def print_tool_result(self, *a: Any, **k: Any) -> None:
101 """Record tool result printing.
103 Args:
104 *a: Positional arguments passed to the logger.
105 **k: Keyword arguments passed to the logger.
106 """
107 self._rec("print_tool_result", *a, **k)
109 def print_execution_summary(self, *a: Any, **k: Any) -> None:
110 """Record execution summary printing.
112 Args:
113 *a: Positional arguments passed to the logger.
114 **k: Keyword arguments passed to the logger.
115 """
116 self._rec("print_execution_summary", *a, **k)
118 def print_post_checks_header(self, *a: Any, **k: Any) -> None:
119 """Record post checks header printing.
121 Args:
122 *a: Positional arguments passed to the logger.
123 **k: Keyword arguments passed to the logger.
124 """
125 self._rec("print_post_checks_header", *a, **k)
127 def save_console_log(self, *a: Any, **k: Any) -> None:
128 """Record console log saving.
130 Args:
131 *a: Positional arguments passed to the logger.
132 **k: Keyword arguments passed to the logger.
133 """
134 self._rec("save_console_log", *a, **k)
137@pytest.fixture
138def fake_logger() -> FakeLogger:
139 """Provide a FakeLogger instance for testing.
141 Returns:
142 FakeLogger: Configured FakeLogger instance for unit testing.
143 """
144 return FakeLogger()