This document covers two distinct testing contexts:
- Template Tests - Tests for the AI-Native Python cookiecutter template itself (i.e. this repository)
- Generated Project Tests - Tests included in projects created from this template (i.e. projects rendered after running
cookiecutter)
These tests ensure the cookiecutter template works correctly and generates valid projects.
# From this repository
task test # Run all template tests with coverage
task unit-test # Run unit tests only
task integration-test # Run integration tests onlyIf you'd like to exclude tests that are marked a certain way, you can pass additional details to the above tasks, for instance:
task test -- "not slow" # Skip slow tests- Generation Validation: Tests with various input combinations to ensure valid project generation
- Hook Execution: Verifies post-generation hooks run correctly
- File Structure: Confirms all expected files are created
- End-to-End: Full test of the default parameter answers including:
- Project initialization
- Dependency installation
- Running generated project's test suite and linters
Every project created from this template includes a complete testing setup.
- 100% Coverage: Template provides tests for the initial
main.pyand module code - Pytest Configuration: Pre-configured in
pyproject.toml - Coverage Requirements: 80% minimum enforced in CI/CD
# From the generated project root
task test # Run all tests with coverage
task unit-test # Run unit tests only
task integration-test # Run integration tests onlyGenerated projects use pytest with:
- Parametrized tests for multiple scenarios
- Markers for test categorization (
@pytest.mark.unit,@pytest.mark.integration) - Mocking for external dependencies
The above tests are a part of what's automatically executed in the CI pipeline. For complete details on test automation and workflow configuration, see the CI/CD Guide.