DEVX-132: fix: check_test_isolation accepts multiple --test-path values
Post-merge / detect-and-configure (push) Successful in 13s
Post-merge / release-and-maintain (push) Successful in 1m0s

This commit was merged in pull request #199.
This commit is contained in:
2026-07-13 01:38:04 +00:00
parent 35f4fb7172
commit 55583fe399
2 changed files with 17 additions and 11 deletions
+1 -1
View File
@@ -385,7 +385,7 @@ devx-check-test-speed:
# This is also automatically enforced by the pytest plugin (pytest11 entry point). # This is also automatically enforced by the pytest plugin (pytest11 entry point).
# Use this target for CI gates or pre-commit hooks. # Use this target for CI gates or pre-commit hooks.
devx-check-test-isolation: devx-check-test-isolation:
@$(DEVX_PYTHON) -m devx.tools.check_test_isolation --test-path $(DEVX_TEST_PATHS) @$(DEVX_PYTHON) -m devx.tools.check_test_isolation $(addprefix --test-path ,$(DEVX_TEST_PATHS))
# Check translation files for missing keys, dead keys, and missing languages. # Check translation files for missing keys, dead keys, and missing languages.
# Runs automatically as part of devx-lint to shift-left translation issues # Runs automatically as part of devx-lint to shift-left translation issues
+16 -10
View File
@@ -449,10 +449,12 @@ def pytest_collection_finish(session): # type: ignore[no-untyped-def] # pragma
@click.command() @click.command()
@click.option( @click.option(
"--test-path", "--test-path",
"test_paths",
type=click.Path(exists=True, path_type=Path), type=click.Path(exists=True, path_type=Path),
default=Path("tests/"), multiple=True,
default=[Path("tests/")],
show_default=True, show_default=True,
help="Path to test directory or file to analyze.", help="Path to test directory or file to analyze (can be specified multiple times).",
) )
@click.option( @click.option(
"--max-loop-iterations", "--max-loop-iterations",
@@ -474,31 +476,35 @@ def pytest_collection_finish(session): # type: ignore[no-untyped-def] # pragma
help="Comma-separated list of categories to check (default: all). " help="Comma-separated list of categories to check (default: all). "
"Available: unpatched-subprocess, unpatched-sleep, unpatched-helper, excessive-iterations", "Available: unpatched-subprocess, unpatched-sleep, unpatched-helper, excessive-iterations",
) )
def cli(test_path: Path, max_loop_iterations: int, strict: bool, categories: str) -> None: def cli(test_paths: tuple[Path, ...], max_loop_iterations: int, strict: bool, categories: str) -> None:
"""Check test files for un-hermetic patterns that cause slow or flaky tests.""" """Check test files for un-hermetic patterns that cause slow or flaky tests."""
allowed: set[str] | None = None allowed: set[str] | None = None
if categories: if categories:
allowed = {c.strip() for c in categories.split(",")} allowed = {c.strip() for c in categories.split(",")}
violations = analyze_test_files(test_path, max_loop_iterations, allowed) all_violations: list[Violation] = []
total_files = 0
for test_path in test_paths:
violations = analyze_test_files(test_path, max_loop_iterations, allowed)
all_violations.extend(violations)
total_files += len(find_test_files(test_path))
if not violations: if not all_violations:
file_count = len(find_test_files(test_path))
click.echo( click.echo(
_("Test isolation check passed: {count} test files analyzed, no violations found.", count=file_count) _("Test isolation check passed: {count} test files analyzed, no violations found.", count=total_files)
) )
sys.exit(0) sys.exit(0)
click.echo( click.echo(
_( _(
"Test isolation check FAILED: {count} violation(s) found in {files} test file(s).", "Test isolation check FAILED: {count} violation(s) found in {files} test file(s).",
count=len(violations), count=len(all_violations),
files=len({v.file for v in violations}), files=len({v.file for v in all_violations}),
), ),
err=True, err=True,
) )
click.echo("") click.echo("")
for v in sorted(violations, key=lambda x: (str(x.file), x.line)): for v in sorted(all_violations, key=lambda x: (str(x.file), x.line)):
click.echo(f" {v.format()}", err=True) click.echo(f" {v.format()}", err=True)
click.echo("") click.echo("")