Coverage for tests / unit / utils / native_parsers / conftest.py: 100%

14 statements  

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

1"""Shared fixtures for native_parsers tests.""" 

2 

3from __future__ import annotations 

4 

5from collections.abc import Iterator 

6from pathlib import Path 

7from unittest.mock import MagicMock, patch 

8 

9import pytest 

10 

11 

12@pytest.fixture 

13def mock_empty_pyproject() -> Iterator[MagicMock]: 

14 """Fixture that mocks load_pyproject to return an empty dict. 

15 

16 Yields: 

17 MagicMock: Mock object for load_pyproject function. 

18 """ 

19 with patch("lintro.utils.config.load_pyproject") as mock_load: 

20 mock_load.return_value = {} 

21 yield mock_load 

22 

23 

24@pytest.fixture 

25def temp_cwd(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path: 

26 """Fixture that changes the current working directory to a temp path. 

27 

28 Args: 

29 tmp_path: Temporary directory path. 

30 monkeypatch: Pytest monkeypatch fixture. 

31 

32 Returns: 

33 The temporary directory path. 

34 """ 

35 monkeypatch.chdir(tmp_path) 

36 return tmp_path