Skip to main content

Testing

Testing Path Header Scanner

Required for Changes

Validate one scanning contract first, then the complete language-aware suite.

Commandpython -m pytest

Category

Developer Guide

Quick Command

python -m pytest [PATH] [OPTIONS]

previewapplylanguagesdry-runpre-commit

Overviewโ€‹

Use temporary source trees for scanner tests. Preview must remain read-only, --apply may update only selected supported files, and --dry-run must override both explicit and configured apply behavior.


Test Layers

Where Scanner Behavior Is Exercised

CLI

tests/cli covers init and scan wiring, path resolution, output, errors, and versions.

Scan Core

tests/core/scan covers discovery, processing, validation, and file updates.

Languages

tests/languages covers Python, JavaScript, HTML, PHP, and shell header strategies.

Integration and Safety

Integration, initialization, configuration, dry-run, service, utility, and developer-workflow tests connect the boundaries.

Focused Validation

Focused pytest examples
bash
# Scanner processing and updates
python -m pytest tests/core/scan

# One language strategy

python -m pytest tests/languages/test_python_strategy.py

# Full scan integration

python -m pytest tests/integration/test_full_scan.py

# Dry-run regression boundaries

python -m pytest tests/test_dry_run.py

On Windows, pass a repository-local --basetemp when the system temporary directory cannot be accessed.


What to Test

Before You Begin

  • PreviewRequired

    Assert discovery and planned changes without target-file writes.

  • ApplyRequired

    Assert only selected supported files receive the expected header insertion or update.

  • Dry-run overrideRequired

    Prove --dry-run overrides --apply and configured apply=true.

  • Language strategyRequired

    Cover syntax, existing valid headers, stale headers, unsupported content, and path rendering.

  • Exclusions and pathsRequired

    Cover workdir, relative targets, ignored directories, virtual environments, caches, and build output.


Pre-Commit Quality Gates

The hook runs Ruff lint fixes, Ruff formatting, Black, trailing-whitespace cleanup, and final-newline correction.

Pre-commit checks
bash
make pre-commit-validate
make pre-commit-run-staged
make pre-commit-run

Protected reference-file exclusions apply even when a hook or editor supplies a matching path explicitly.


Complete Validation

Full quality checks
bash
python -m pytest
make check

For developer-workflow changes, also validate make help, representative Make dry-runs, Docker and Compose configuration, and development and production CLI --help startup. Do not publish packages or images during routine validation.