Coverage for tests / unit / tools / ruff / check / test_real_plugin.py: 100%
16 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 with real RuffPlugin instance."""
3from __future__ import annotations
5from typing import TYPE_CHECKING
6from unittest.mock import patch
8from assertpy import assert_that
10from lintro.enums.tool_name import ToolName
11from lintro.tools.implementations.ruff.check import execute_ruff_check
13if TYPE_CHECKING:
14 from lintro.tools.definitions.ruff import RuffPlugin
17def test_execute_ruff_check_with_real_plugin_no_files(
18 ruff_plugin: RuffPlugin,
19) -> None:
20 """Execute with real plugin when no files to check.
22 Args:
23 ruff_plugin: RuffPlugin instance for testing.
24 """
25 with patch.object(ruff_plugin, "_verify_tool_version", return_value=None):
26 result = execute_ruff_check(ruff_plugin, [])
28 assert_that(result.success).is_true()
29 assert_that(result.output).is_equal_to("No files to check.")
32def test_execute_ruff_check_with_real_plugin(
33 ruff_plugin: RuffPlugin,
34 temp_python_file: str,
35) -> None:
36 """Execute with real plugin and temp file.
38 Args:
39 ruff_plugin: RuffPlugin instance for testing.
40 temp_python_file: Temporary Python file for testing.
41 """
42 with (
43 patch.object(ruff_plugin, "_verify_tool_version", return_value=None),
44 patch(
45 "lintro.tools.implementations.ruff.check.run_subprocess_with_timeout",
46 return_value=(True, "[]"),
47 ),
48 ):
49 result = execute_ruff_check(ruff_plugin, [temp_python_file])
51 assert_that(result.success).is_true()
52 assert_that(result.name).is_equal_to(ToolName.RUFF)