Coverage for tests / unit / config / test_config_loader_more.py: 100%
14 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"""Extra tests for config loader covering post_checks happy path."""
3from __future__ import annotations
5from pathlib import Path
7import pytest
8from assertpy import assert_that
10from lintro.utils.config import (
11 clear_pyproject_cache,
12 load_post_checks_config,
13)
16def test_load_post_checks_config_present(
17 tmp_path: Path,
18 monkeypatch: pytest.MonkeyPatch,
19) -> None:
20 """Load post-checks config from pyproject.
22 Args:
23 tmp_path: Temporary directory to host a pyproject.
24 monkeypatch: Pytest monkeypatch for chdir.
25 """
26 # Clear LRU caches to ensure we load from the test directory
27 clear_pyproject_cache()
29 pyproject = tmp_path / "pyproject.toml"
30 pyproject.write_text(
31 (
32 "[tool.lintro.post_checks]\n"
33 "enabled = true\n"
34 'tools = ["black"]\n'
35 "enforce_failure = true\n"
36 ),
37 )
38 monkeypatch.chdir(tmp_path)
39 cfg = load_post_checks_config()
40 assert_that(cfg.get("enabled") is True).is_true()
41 assert_that(cfg.get("tools")).is_equal_to(["black"])
42 assert_that(cfg.get("enforce_failure") is True).is_true()