Test copier templates
Project description
copier-template-tester
Parametrize copier templates to test for syntax errors, check the expected output, and to check against copier versions.
Note that ctt
only tests the copier copy
operation and doesn't check the update
behavior and any version-specific logic that your template may contain because of how quickly those tests become complex.
Usage
Configuration File
When creating a copier template repository, I recommend following the nested "subdirectory" approach so that the directory looks like this:
└── template_dir
│ └── {{ _copier_conf.answers_file }}.jinja
├── README.md
├── copier.yml
└── ctt.toml
Create a new ctt.toml
file in the top-level directory of your copier repository. Populate the file to look like the below example.
# Specify shared data across all 'output' destinations
# Note that the copier.yml defaults are used whenever the key is not set in this file
[defaults]
project_name = "placeholder"
copyright_year = 2022
# Parametrize each output with a relative path and optionally any values to override
[output.".ctt/defaults"]
[output.".ctt/no_all"]
package_name = "testing-no-all"
include_all = false
Pre-Commit Hook
First, add this section to your .pre-commit-config.yml
file:
repos:
- repo: https://github.com/KyleKing/copier-template-tester
rev: main
hooks:
- id: copier-template-tester
Install and update to the latest revision:
pre-commit autoupdate
The run with pre-commit
:
pre-commit run --all-files copier-template-tester
pipx
You can also try ctt
as a CLI tool by installing with pipx
:
pipx install copier-template-tester
cd ~/your/copier/project
ctt
More Examples
For more example code, see the scripts directory or the tests.
Project Status
See the Open Issues
and/or the CODE_TAG_SUMMARY. For release history, see the CHANGELOG.
Contributing
We welcome pull requests! For your pull request to be accepted smoothly, we suggest that you first open a GitHub issue to discuss your idea. For resources on getting started with the code base, see the below documentation:
Code of Conduct
We follow the Contributor Covenant Code of Conduct.
Open Source Status
We try to reasonably meet most aspects of the "OpenSSF scorecard" from Open Source Insights
Responsible Disclosure
If you have any security issue to report, please contact the project maintainers privately. You can reach us at dev.act.kyle@gmail.com.
License
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for copier_template_tester-2.1.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 55a9ba2fb2a13f673b2eb458897148d02ca30582f5e9ef03d5de8a88136d4afb |
|
MD5 | 788693c83efec65bd9c83937db7ae97f |
|
BLAKE2b-256 | 39dfd25730fe1e4db911d10721ab4746c6586b7df53eb8e0c8c118fb4f5b02d3 |
Hashes for copier_template_tester-2.1.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 416c9fc20efda10e48bcec625db999fb906c56ceb28ff5ff410e6a748bdcf3d0 |
|
MD5 | 5256c7257efa36b781caadf76ae811cb |
|
BLAKE2b-256 | 4d574ec0ce9afc680e7885dfedf79c7cef2ce63648930621245617f69151e5e7 |