Coverage for tests/conftest.py: 100.00%

15 statements  

« prev     ^ index     » next       coverage.py v7.4.4, created at 2024-04-02 00:26 +0200

1"""Configuration for the pytest test suite.""" 

2 

3from __future__ import annotations 

4 

5from typing import TYPE_CHECKING 

6 

7import pytest 

8 

9from git_changelog.commit import AngularConvention 

10from tests.helpers import GitRepo 

11 

12if TYPE_CHECKING: 

13 from pathlib import Path 

14 

15 

16@pytest.fixture(name="repo") 

17def git_repo(tmp_path: Path, request: pytest.FixtureRequest) -> GitRepo: 

18 """Pytest fixture setting up a temporary Git repository. 

19 

20 Parameters: 

21 tmp_path: Path to a temporary directory (pytest fixture). 

22 

23 Yields: 

24 A Git repository wrapper instance. 

25 """ 

26 repo = GitRepo(tmp_path) 

27 versions = getattr(request, "param", []) 

28 for version in versions: 

29 for section in AngularConvention.TYPES: 

30 repo.commit(f"{section}: Summary.") 

31 if version: 

32 repo.git("tag", version) 

33 return repo