11from dataclasses import dataclass
22from pathlib import Path
3+ from typing import Any
34
45import pytest
56
@@ -33,21 +34,41 @@ def repo_root() -> Path:
3334 return Path (__file__ ).resolve ().parents [2 ]
3435
3536
36- def discover_cases ():
37+ def discover_cases () -> list [ Any ] :
3738 """
3839 Discover all regression test cases from the configs directory.
3940
40- Iterates over each system directory under `tests/regression/configs`,
41- and collects all YAML configuration files. Each configuration file is
42- paired with a corresponding baseline JSON file.
41+ This function scans the regression configuration directory structure and
42+ constructs a list of parametrized pytest cases. Each case corresponds to
43+ a single YAML configuration file and its associated baseline JSON file.
44+
45+ Directory structure is expected to follow:
46+
47+ tests/regression/configs/<system>/<config>.yaml
48+ tests/regression/baselines/<system>/<config>.json
49+
50+ For each configuration file:
51+ - A `RegressionCase` instance is created.
52+ - A pytest parameter is generated with a unique ID.
53+ - Slow tests are automatically marked using `pytest.mark.slow`
54+ based on configuration naming conventions.
55+
56+ Slow Test Heuristic:
57+ Configurations considered "slow" are those representing full-system
58+ or full-selection runs. These are explicitly identified by name
59+ (e.g. "default", "rad") and are marked with `pytest.mark.slow`.
60+ All other configurations (typically subset-based runs such as
61+ selection subsets) are treated as fast tests.
4362
4463 Returns:
45- list[pytest.Param ]: A list of parametrized pytest cases, each wrapping
46- a RegressionCase instance.
64+ list[Any ]: A list of parametrized pytest cases, each wrapping a
65+ RegressionCase instance and optionally marked as slow .
4766
4867 Notes:
49- - Cases are automatically marked as slow unless the system is "dna".
5068 - Baseline files are not required to exist at discovery time.
69+ - Missing baselines will cause failures during test execution unless
70+ `--update-baselines` is used.
71+ - Test IDs are generated in the form: "{system}-{config_name}".
5172 """
5273 base_dir = Path (__file__ ).resolve ().parent
5374
@@ -56,6 +77,8 @@ def discover_cases():
5677
5778 cases = []
5879
80+ SLOW_CONFIGS = {"default" , "rad" }
81+
5982 for system_dir in sorted (configs_root .iterdir ()):
6083 if not system_dir .is_dir ():
6184 continue
@@ -67,12 +90,13 @@ def discover_cases():
6790
6891 baseline_path = baselines_root / system / f"{ case_name } .json"
6992
70- # DO NOT skip if baseline is missing
93+ is_slow = case_name in SLOW_CONFIGS
94+
7195 cases .append (
7296 pytest .param (
7397 RegressionCase (system , config_path , baseline_path ),
7498 id = f"{ system } -{ case_name } " ,
75- marks = pytest .mark .slow if system != "dna" else (),
99+ marks = pytest .mark .slow if is_slow else (),
76100 )
77101 )
78102
0 commit comments