Coverage for tests / integration / tools / shellcheck / test_definition.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 ShellcheckPlugin definition attributes.
3These tests verify the plugin definition has correct metadata and configuration.
4"""
6from __future__ import annotations
8import shutil
9from collections.abc import Callable
10from typing import TYPE_CHECKING
12import pytest
13from assertpy import assert_that
15if TYPE_CHECKING:
16 from lintro.plugins.base import BaseToolPlugin
18pytestmark = pytest.mark.skipif(
19 shutil.which("shellcheck") is None,
20 reason="shellcheck not installed",
21)
24@pytest.mark.parametrize(
25 ("attr", "expected"),
26 [
27 ("name", "shellcheck"),
28 ("can_fix", False),
29 ],
30 ids=["name", "can_fix"],
31)
32def test_definition_attributes(
33 get_plugin: Callable[[str], BaseToolPlugin],
34 attr: str,
35 expected: object,
36) -> None:
37 """Verify ShellcheckPlugin definition has correct attribute values.
39 Args:
40 get_plugin: Fixture factory to get plugin instances.
41 attr: The attribute name to check on the definition.
42 expected: The expected value of the attribute.
43 """
44 shellcheck_plugin = get_plugin("shellcheck")
45 assert_that(getattr(shellcheck_plugin.definition, attr)).is_equal_to(expected)
48def test_definition_file_patterns(
49 get_plugin: Callable[[str], BaseToolPlugin],
50) -> None:
51 """Verify ShellcheckPlugin definition includes shell file patterns.
53 ShellCheck officially supports bash, sh, dash, and ksh dialects.
55 Args:
56 get_plugin: Fixture factory to get plugin instances.
57 """
58 shellcheck_plugin = get_plugin("shellcheck")
59 assert_that(shellcheck_plugin.definition.file_patterns).contains("*.sh")
60 assert_that(shellcheck_plugin.definition.file_patterns).contains("*.bash")
61 assert_that(shellcheck_plugin.definition.file_patterns).contains("*.ksh")
64def test_definition_has_version_command(
65 get_plugin: Callable[[str], BaseToolPlugin],
66) -> None:
67 """Verify ShellcheckPlugin definition has a version command.
69 Args:
70 get_plugin: Fixture factory to get plugin instances.
71 """
72 shellcheck_plugin = get_plugin("shellcheck")
73 assert_that(shellcheck_plugin.definition.version_command).is_not_none()