Coverage for tests / unit / formatters / styles / test_style_grid.py: 100%
18 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"""Unit tests for GridStyle formatter.
3Tests verify GridStyle correctly formats tabular data as grid-style
4tables with borders and proper alignment.
5"""
7from __future__ import annotations
9from assertpy import assert_that
11from lintro.formatters.styles.grid import GridStyle
13from .conftest import MULTI_ROW_DATA, SINGLE_ROW_DATA, STANDARD_COLUMNS, TWO_COLUMNS
16def test_grid_style_single_row_contains_header_and_data(
17 grid_style: GridStyle,
18) -> None:
19 """GridStyle format includes header and data values.
21 Args:
22 grid_style: The GridStyle formatter instance.
23 """
24 result = grid_style.format(STANDARD_COLUMNS, SINGLE_ROW_DATA)
26 assert_that(result).contains("File")
27 assert_that(result).contains("src/main.py")
30def test_grid_style_multiple_rows_contains_all_files(grid_style: GridStyle) -> None:
31 """GridStyle format includes all file paths from multiple rows.
33 Args:
34 grid_style: The GridStyle formatter instance.
35 """
36 result = grid_style.format(TWO_COLUMNS, MULTI_ROW_DATA)
38 assert_that(result).contains("src/a.py")
39 assert_that(result).contains("src/b.py")
42def test_grid_style_column_alignment_produces_output(grid_style: GridStyle) -> None:
43 """GridStyle with alignment columns produces non-empty formatted output.
45 Args:
46 grid_style: The GridStyle formatter instance.
47 """
48 result = grid_style.format(
49 ["File", "Line", "Column", "Fixable"],
50 [["src/main.py", "10", "5", "Yes"]],
51 )
53 assert_that(result).is_not_empty()
56def test_grid_style_empty_columns_handles_gracefully(grid_style: GridStyle) -> None:
57 """GridStyle handles empty columns list without error.
59 Args:
60 grid_style: The GridStyle formatter instance.
61 """
62 result = grid_style.format([], [["data"]])
64 assert_that(result).is_not_none()