Testing¶
Configurator uses pytest and click.testing.CliRunner.
Most tests execute the CLI and validate the generated YAML rather than testing internals in isolation.
Running tests¶
If you use Hatch:
Available scripts from pyproject.toml:
hatch run test:testhatch run test:test-qhatch run test:test-covhatch run test:test-show-setup
If you use the task runner:
That task currently runs hatch run test:test-show-setup.
Test structure¶
Current coverage is organized around:
- CLI generation:
tests/test_cli_dump_config.py - overrides and node selectors:
tests/test_cli_overrides.py - CLI failures and validation errors:
tests/test_cli_failures.py - listing and describing profiles:
tests/test_cli_list_describe.py - structured manifest dumping:
tests/test_cli_manifests_dumping.py - external plugin loading:
tests/test_cli_external_profiles.pyandtests/test_external_profiles.py - registry behavior:
tests/test_registry.py
Test patterns¶
Common pattern:
- use
CliRunner - invoke
configurator.main.main - write output to a temporary file
- parse YAML with test helpers
- assert on generated structure
Example:
Registry isolation¶
The suite uses autouse fixtures in tests/conftest.py to clear the global profile_registry between tests.
That matters because:
- built-in profiles register at import time
- plugin tests import external modules dynamically
- duplicate registrations would otherwise leak across tests
When adding tests¶
For a new profile or feature, prefer adding tests that exercise user-visible behavior:
- successful config generation
- override handling
- failure messages for invalid input
- manifest structure when YAML documents are involved
This keeps the suite aligned with the CLI contract.