Coverage for tests / unit / config / test_enforce_config.py: 100%
32 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 lintro.config.enforce_config module."""
3from __future__ import annotations
5import pytest
6from assertpy import assert_that
8from lintro.config.enforce_config import EnforceConfig
11def test_enforce_config_default_line_length() -> None:
12 """EnforceConfig has None line_length by default."""
13 config = EnforceConfig()
14 assert_that(config.line_length).is_none()
17def test_enforce_config_default_target_python() -> None:
18 """EnforceConfig has None target_python by default."""
19 config = EnforceConfig()
20 assert_that(config.target_python).is_none()
23def test_enforce_config_set_line_length() -> None:
24 """EnforceConfig accepts line_length value."""
25 config = EnforceConfig(line_length=88)
26 assert_that(config.line_length).is_equal_to(88)
29def test_enforce_config_set_target_python() -> None:
30 """EnforceConfig accepts target_python value."""
31 config = EnforceConfig(target_python="py313")
32 assert_that(config.target_python).is_equal_to("py313")
35def test_enforce_config_full_init() -> None:
36 """EnforceConfig accepts all parameters."""
37 config = EnforceConfig(line_length=120, target_python="py311")
38 assert_that(config.line_length).is_equal_to(120)
39 assert_that(config.target_python).is_equal_to("py311")
42def test_enforce_config_line_length_minimum() -> None:
43 """EnforceConfig enforces minimum line_length of 1."""
44 with pytest.raises(ValueError, match="greater than or equal to 1"):
45 EnforceConfig(line_length=0)
48def test_enforce_config_line_length_maximum() -> None:
49 """EnforceConfig enforces maximum line_length of 500."""
50 with pytest.raises(ValueError, match="less than or equal to 500"):
51 EnforceConfig(line_length=501)
54def test_enforce_config_line_length_boundary_min() -> None:
55 """EnforceConfig accepts minimum line_length of 1."""
56 config = EnforceConfig(line_length=1)
57 assert_that(config.line_length).is_equal_to(1)
60def test_enforce_config_line_length_boundary_max() -> None:
61 """EnforceConfig accepts maximum line_length of 500."""
62 config = EnforceConfig(line_length=500)
63 assert_that(config.line_length).is_equal_to(500)