Coverage for tests / unit / tools / ruff / fix / test_no_files.py: 100%
19 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 - No files scenarios."""
3from __future__ import annotations
5from typing import Any
6from unittest.mock import MagicMock, patch
8from assertpy import assert_that
10from lintro.tools.implementations.ruff.fix import execute_ruff_fix
13def test_execute_ruff_fix_no_paths(mock_ruff_tool: MagicMock) -> None:
14 """Return success with no files message when paths list is empty.
16 Args:
17 mock_ruff_tool: Mock RuffTool instance for testing.
18 """
19 result = execute_ruff_fix(mock_ruff_tool, [])
21 assert_that(result.success).is_true()
22 assert_that(result.output).is_equal_to("No files to fix.")
23 assert_that(result.issues_count).is_equal_to(0)
26def test_execute_ruff_fix_no_python_files_found(
27 mock_ruff_tool: MagicMock,
28 tmp_path: Any,
29) -> None:
30 """Return success with no Python files message when no .py files exist.
32 Args:
33 mock_ruff_tool: Mock RuffTool instance for testing.
34 tmp_path: Temporary directory path for testing.
35 """
36 # Create a non-Python file
37 text_file = tmp_path / "readme.txt"
38 text_file.write_text("Hello")
40 with patch(
41 "lintro.tools.implementations.ruff.fix.walk_files_with_excludes",
42 ) as mock_walk:
43 mock_walk.return_value = []
45 result = execute_ruff_fix(mock_ruff_tool, [str(tmp_path)])
47 assert_that(result.success).is_true()
48 assert_that(result.output).is_equal_to("No Python files found to fix.")
49 assert_that(result.issues_count).is_equal_to(0)