Coverage for tests / scripts / conftest.py: 53%
15 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"""Shared fixtures for CI script tests."""
3import tempfile
4from collections.abc import Generator
5from pathlib import Path
7import pytest
10@pytest.fixture
11def temp_script_dir() -> Generator[Path, None, None]:
12 """Create a temporary directory with script testing setup.
14 Yields:
15 Path: Path to the temporary directory.
16 """
17 with tempfile.TemporaryDirectory() as tmpdir:
18 script_dir = Path(tmpdir)
19 # Copy necessary files for script testing
20 yield script_dir
23@pytest.fixture
24def mock_github_env(monkeypatch: pytest.MonkeyPatch) -> dict[str, str]:
25 """Mock GitHub Actions environment variables.
27 Args:
28 monkeypatch: Pytest monkeypatch fixture for environment manipulation.
30 Returns:
31 dict: Dictionary of mocked environment variables.
32 """
33 env_vars = {
34 "GITHUB_TOKEN": "mock-token",
35 "GITHUB_REPOSITORY": "test/repo",
36 "GITHUB_EVENT_NAME": "pull_request",
37 "GITHUB_REF": "refs/pull/123/merge",
38 "GITHUB_SHA": "abc123def456",
39 }
41 for key, value in env_vars.items():
42 monkeypatch.setenv(key, value)
44 return env_vars