Skip to content

Commit 489bd66

Browse files
committed
tests: update project.toml to use parallel flag correctly
1 parent e91dac1 commit 489bd66

3 files changed

Lines changed: 33 additions & 16 deletions

File tree

pyproject.toml

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,13 @@ docs = [
8585
CodeEntropy = "CodeEntropy.cli:main"
8686

8787
[tool.pytest.ini_options]
88-
addopts = "-n auto -ra -vv --dist=loadscope"
88+
testpaths = ["tests"]
8989

90-
markers = [
91-
"regression: end-to-end regression tests against baselines",
92-
"slow: long-running regression tests (20-30+ minutes)"
93-
]
90+
addopts = "-n auto -vv -ra"
9491

95-
testpaths = [
96-
"tests/unit",
97-
"tests/regression"
92+
markers = [
93+
"regression: end-to-end regression tests against baselines",
94+
"slow: long-running regression tests (20-30+ minutes)",
9895
]
9996

10097
[tool.ruff]

tests/__init__.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
"""
2-
Empty init file in case you choose a package besides PyTest such as Nose which may look
3-
for such a file.
4-
"""
1+
""" """

tests/regression/test_regression.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,27 @@
1010
from tests.regression.cases import discover_cases
1111
from tests.regression.helpers import run_codeentropy_with_config
1212

13+
CASES = discover_cases()
14+
15+
16+
def pytest_generate_tests(metafunc: pytest.Metafunc) -> None:
17+
"""
18+
Dynamically parametrize regression test cases.
19+
20+
This hook enables pytest-xdist to distribute individual regression cases
21+
across multiple workers by generating test parametrization at collection time.
22+
23+
Args:
24+
metafunc (pytest.Metafunc): Pytest metafunction object used to inspect
25+
and modify test function parametrization.
26+
"""
27+
if "case" in metafunc.fixturenames:
28+
metafunc.parametrize(
29+
"case",
30+
CASES,
31+
ids=[c.id for c in CASES],
32+
)
33+
1334

1435
def _group_index(payload: dict[str, Any]) -> dict[str, dict[str, Any]]:
1536
"""
@@ -106,9 +127,10 @@ def _compare_grouped(
106127

107128

108129
@pytest.mark.regression
109-
@pytest.mark.parametrize("case", discover_cases())
110130
def test_regression_matches_baseline(
111-
tmp_path: Path, case, request: pytest.FixtureRequest
131+
tmp_path: Path,
132+
case,
133+
request: pytest.FixtureRequest,
112134
) -> None:
113135
"""
114136
Execute a regression test for a single scenario and compare against baseline.
@@ -121,8 +143,9 @@ def test_regression_matches_baseline(
121143
122144
Args:
123145
tmp_path (Path): Temporary directory provided by pytest.
124-
case (RegressionCase): Parameterized regression case.
125-
request (pytest.FixtureRequest): Pytest request object for accessing CLI options
146+
case: A RegressionCase instance containing system, config, and baseline paths.
147+
request (pytest.FixtureRequest): Pytest request object used to access CLI
148+
options.
126149
127150
Raises:
128151
AssertionError: If the output does not match the baseline or baseline is missing

0 commit comments

Comments
 (0)