-
Notifications
You must be signed in to change notification settings - Fork 405
Expand file tree
/
Copy pathtest_setup_validation.py
More file actions
112 lines (89 loc) · 3.88 KB
/
test_setup_validation.py
File metadata and controls
112 lines (89 loc) · 3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
import subprocess
import sys
from pathlib import Path
import pytest
class TestSetupValidation:
"""Validation tests to ensure the testing infrastructure is properly configured."""
def test_pytest_installed(self):
"""Verify pytest is installed and importable."""
import pytest
assert pytest.__version__
def test_pytest_cov_installed(self):
"""Verify pytest-cov is installed and importable."""
import pytest_cov
assert pytest_cov.__version__
def test_pytest_mock_installed(self):
"""Verify pytest-mock is installed and importable."""
try:
import pytest_mock
# pytest-mock doesn't have __version__, just verify it imports
assert pytest_mock
except ImportError:
pytest.fail("pytest-mock is not installed")
def test_project_structure_exists(self):
"""Verify the expected project structure exists."""
project_root = Path(__file__).parent.parent
# Check main directories
assert project_root.exists()
assert (project_root / "tests").exists()
assert (project_root / "tests" / "unit").exists()
assert (project_root / "tests" / "integration").exists()
# Check configuration files
assert (project_root / "pyproject.toml").exists()
assert (project_root / "tests" / "conftest.py").exists()
def test_pyproject_toml_valid(self):
"""Verify pyproject.toml is valid and contains expected sections."""
project_root = Path(__file__).parent.parent
pyproject_path = project_root / "pyproject.toml"
assert pyproject_path.exists()
content = pyproject_path.read_text()
assert "[tool.poetry]" in content
assert "[tool.pytest.ini_options]" in content
assert "[tool.coverage.run]" in content
assert "[tool.coverage.report]" in content
@pytest.mark.unit
def test_unit_marker(self):
"""Test that the unit marker works correctly."""
assert True
@pytest.mark.integration
def test_integration_marker(self):
"""Test that the integration marker works correctly."""
assert True
@pytest.mark.slow
def test_slow_marker(self):
"""Test that the slow marker works correctly."""
assert True
def test_conftest_fixtures_available(self, temp_dir, mock_config):
"""Verify that fixtures from conftest.py are available."""
assert temp_dir.exists()
assert temp_dir.is_dir()
assert isinstance(mock_config, dict)
assert "project_name" in mock_config
assert mock_config["project_name"] == "test_project"
def test_sphinx_fixtures_available(self, source_dir, sphinx_build_dir):
"""Verify Sphinx-specific fixtures are available."""
assert source_dir.exists()
assert (source_dir / "conf.py").exists()
assert (source_dir / "index.rst").exists()
assert sphinx_build_dir.exists()
assert (sphinx_build_dir / "html").exists()
assert (sphinx_build_dir / "doctrees").exists()
def test_coverage_configuration(self):
"""Verify coverage is properly configured."""
project_root = Path(__file__).parent.parent
pyproject_path = project_root / "pyproject.toml"
content = pyproject_path.read_text()
# Check coverage settings
assert "--cov-branch" in content
assert "--cov-report=html" in content
assert "--cov-report=xml" in content
def test_poetry_run_commands(self):
"""Verify Poetry run commands work correctly."""
# Test that we can run pytest through poetry
result = subprocess.run(
["poetry", "run", "pytest", "--version"],
capture_output=True,
text=True
)
assert result.returncode == 0
assert "pytest" in result.stdout