Skip to content

refactor(tests): split test_template.py to enforce 400-line module limit #36

@coderabbitai

Description

@coderabbitai

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 helpersread_generated_text, parse_toml_file, parse_yaml_mapping, require_mapping, require_optional_mapping
  • Tooling-contract assertion helpersassert_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 teststest_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

  1. Create tests/support/__init__.py (empty or with a brief docstring).
  2. 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).
  3. Update tests/test_template.py to import from tests.support.tooling_asserts instead of defining these locally.
  4. Ensure tests/test_template.py falls below 400 logical lines and contains only scenario-level fixtures and test functions.
  5. Verify all tests pass (make test) after the relocation.

References

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions