Coverage for tests / unit / tools / ruff / fix / test_config.py: 100%
10 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"""Tests for execute_ruff_fix - Config file scenarios."""
3from __future__ import annotations
5from unittest.mock import MagicMock, patch
7from lintro.tools.implementations.ruff.fix import execute_ruff_fix
10def test_execute_ruff_fix_uses_config_args(
11 mock_ruff_tool: MagicMock,
12 sample_ruff_json_empty_output: str,
13) -> None:
14 """Use config args from _build_config_args when available.
16 Args:
17 mock_ruff_tool: Mock RuffTool instance for testing.
18 sample_ruff_json_empty_output: Sample empty JSON output from ruff.
19 """
20 mock_ruff_tool._build_config_args.return_value = ["--line-length", "100"]
22 with patch(
23 "lintro.tools.implementations.ruff.fix.walk_files_with_excludes",
24 ) as mock_walk:
25 mock_walk.return_value = ["test.py"]
27 mock_ruff_tool._run_subprocess.side_effect = [
28 (True, sample_ruff_json_empty_output),
29 (True, sample_ruff_json_empty_output),
30 ]
32 execute_ruff_fix(mock_ruff_tool, ["test.py"])
34 # Verify _build_config_args was called (via build_ruff_check_command)
35 mock_ruff_tool._build_config_args.assert_called()