Coverage for cli / tests / conftest.py: 100%

20 statements  

« prev     ^ index     » next       coverage.py v7.14.0, created at 2026-06-19 09:10 +0000

1import os 

2from collections.abc import Iterator 

3from unittest.mock import AsyncMock, patch 

4 

5import pytest 

6import stamina 

7from typer import rich_utils 

8 

9 

10@pytest.fixture 

11def mock_main() -> Iterator[AsyncMock]: 

12 with patch("covered.cli._main", AsyncMock(return_value=None)) as m: 

13 yield m 

14 

15 

16@pytest.fixture(autouse=True) 

17def _isolate_covered_env(monkeypatch: pytest.MonkeyPatch) -> None: 

18 """ 

19 Clear `COVERED_*` env vars from the parent shell so tests aren't polluted. 

20 """ 

21 for var in [k for k in os.environ if k.startswith("COVERED_")]: 

22 monkeypatch.delenv(var) # pragma: no cover 

23 

24 

25@pytest.fixture(autouse=True, scope="session") 

26def _set_stamina_testing(): 

27 stamina.set_testing(True, attempts=10, cap=True) 

28 

29 

30@pytest.fixture(autouse=True, scope="session") 

31def setup_terminal() -> None: 

32 rich_utils.MAX_WIDTH = 3000 

33 rich_utils.FORCE_TERMINAL = False