Coverage for tests / unit / parsers / shellcheck_parser / test_invalid_input.py: 100%
17 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 shellcheck parser handling of invalid/empty input."""
3from __future__ import annotations
5import pytest
6from assertpy import assert_that
8from lintro.parsers.shellcheck.shellcheck_parser import parse_shellcheck_output
11@pytest.mark.parametrize(
12 "output",
13 [
14 None,
15 "",
16 " \n \n ",
17 ],
18 ids=["none", "empty", "whitespace_only"],
19)
20def test_parse_returns_empty_for_no_content(
21 output: str | None,
22) -> None:
23 """Parse empty, None, or whitespace-only output returns empty list.
25 Args:
26 output: The shellcheck output to parse.
27 """
28 result = parse_shellcheck_output(output=output)
29 assert_that(result).is_empty()
32def test_parse_returns_empty_for_invalid_json() -> None:
33 """Parse invalid JSON returns empty list."""
34 result = parse_shellcheck_output(output="not valid json")
35 assert_that(result).is_empty()
38def test_parse_returns_empty_for_non_array_json() -> None:
39 """Parse JSON that is not an array returns empty list."""
40 result = parse_shellcheck_output(output='{"key": "value"}')
41 assert_that(result).is_empty()
44def test_parse_empty_array() -> None:
45 """Parse empty JSON array returns empty list."""
46 result = parse_shellcheck_output(output="[]")
47 assert_that(result).is_empty()