Summary
tests/test_template.py currently exceeds 400 logical lines, violating the repository guideline that files must not exceed 400 logical lines and should be decomposed into subpackages when they do.
Problem
The module bundles three distinct concerns in one file:
- Parsing helpers —
read_generated_text, parse_toml_file, parse_yaml_mapping, require_mapping, require_optional_mapping
- Tooling-contract assertion helpers —
assert_cargo_contracts, assert_makefile_contracts, assert_cargo_config_contracts, assert_ci_workflow_contracts, assert_toolchain_contracts, assert_readme_contracts, assert_test_stub_contracts, assert_release_workflow_contracts, extract_checkout_steps
- Scenario-level tests —
test_template_renders, test_generated_tooling_contracts, test_generated_structured_file_snapshots, etc.
Mixing these in one file makes it harder to locate failures, increases cyclomatic complexity, and violates the single-responsibility guideline.
Proposed Action
- Create
tests/support/__init__.py (empty or with a brief docstring).
- Create
tests/support/tooling_asserts.py and move all tooling-contract assertion helpers into it, along with any parsing utilities they depend on (require_mapping, extract_checkout_steps, parse_toml_file, parse_yaml_mapping, read_generated_text).
- Update
tests/test_template.py to import from tests.support.tooling_asserts instead of defining these locally.
- Ensure
tests/test_template.py falls below 400 logical lines and contains only scenario-level fixtures and test functions.
- Verify all tests pass (
make test) after the relocation.
References
Summary
tests/test_template.pycurrently exceeds 400 logical lines, violating the repository guideline that files must not exceed 400 logical lines and should be decomposed into subpackages when they do.Problem
The module bundles three distinct concerns in one file:
read_generated_text,parse_toml_file,parse_yaml_mapping,require_mapping,require_optional_mappingassert_cargo_contracts,assert_makefile_contracts,assert_cargo_config_contracts,assert_ci_workflow_contracts,assert_toolchain_contracts,assert_readme_contracts,assert_test_stub_contracts,assert_release_workflow_contracts,extract_checkout_stepstest_template_renders,test_generated_tooling_contracts,test_generated_structured_file_snapshots, etc.Mixing these in one file makes it harder to locate failures, increases cyclomatic complexity, and violates the single-responsibility guideline.
Proposed Action
tests/support/__init__.py(empty or with a brief docstring).tests/support/tooling_asserts.pyand move all tooling-contract assertion helpers into it, along with any parsing utilities they depend on (require_mapping,extract_checkout_steps,parse_toml_file,parse_yaml_mapping,read_generated_text).tests/test_template.pyto import fromtests.support.tooling_assertsinstead of defining these locally.tests/test_template.pyfalls below 400 logical lines and contains only scenario-level fixtures and test functions.make test) after the relocation.References
tests/test_template.pylines 411–579