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

1"""Tests with real RuffPlugin instance.""" 

2 

3from __future__ import annotations 

4 

5from typing import TYPE_CHECKING 

6from unittest.mock import patch 

7 

8from assertpy import assert_that 

9 

10from lintro.enums.tool_name import ToolName 

11from lintro.tools.implementations.ruff.check import execute_ruff_check 

12 

13if TYPE_CHECKING: 

14 from lintro.tools.definitions.ruff import RuffPlugin 

15 

16 

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. 

21 

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, []) 

27 

28 assert_that(result.success).is_true() 

29 assert_that(result.output).is_equal_to("No files to check.") 

30 

31 

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. 

37 

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]) 

50 

51 assert_that(result.success).is_true() 

52 assert_that(result.name).is_equal_to(ToolName.RUFF)