Coverage for tests / unit / config / conftest.py: 50%

16 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-04-03 18:53 +0000

1"""Shared fixtures for config unit tests.""" 

2 

3from __future__ import annotations 

4 

5from pathlib import Path 

6from unittest.mock import MagicMock 

7 

8import pytest 

9 

10 

11@pytest.fixture 

12def temp_config_dir(tmp_path: Path) -> Path: 

13 """Provide a temporary directory with config files. 

14 

15 Args: 

16 tmp_path: Pytest temporary path fixture. 

17 

18 Returns: 

19 Path: Path to temporary config directory. 

20 """ 

21 config_dir = tmp_path / "config" 

22 config_dir.mkdir() 

23 

24 # Create sample pyproject.toml 

25 pyproject_content = """ 

26[tool.lintro] 

27line_length = 88 

28 

29[tool.ruff] 

30line-length = 88 

31 

32[tool.black] 

33line_length = 88 

34""" 

35 (config_dir / "pyproject.toml").write_text(pyproject_content) 

36 

37 return config_dir 

38 

39 

40@pytest.fixture 

41def mock_config_loader() -> MagicMock: 

42 """Provide a mock config loader for testing. 

43 

44 Returns: 

45 MagicMock: Mock config loader instance. 

46 """ 

47 loader = MagicMock() 

48 loader.load_config.return_value = { 

49 "line_length": 88, 

50 "tool_order": "priority", 

51 } 

52 return loader