# copier-template-tester
![./ctt-logo.png](./ctt-logo.png)
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](https://copier.readthedocs.io/en/latest/configuring/#subdirectory) so that the directory looks like this:
```sh
└── 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.
```toml
# 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:
```yaml
repos:
- repo: https://github.com/KyleKing/copier-template-tester
rev: main
hooks:
- id: copier-template-tester
```
Install and update to the latest revision:
```sh
pre-commit autoupdate
```
The run with `pre-commit`:
```sh
pre-commit run --all-files copier-template-tester
```
### pipx
You can also try `ctt` as a CLI tool by installing with `pipx`:
```sh
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:
- [DEVELOPER_GUIDE]
- [STYLE_GUIDE]
## Code of Conduct
We follow the [Contributor Covenant Code of Conduct][contributor-covenant].
### Open Source Status
We try to reasonably meet most aspects of the "OpenSSF scorecard" from [Open Source Insights](https://deps.dev/pypi/copier-template-tester)
## 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](mailto:dev.act.kyle@gmail.com).
## License
[LICENSE]
[changelog]: https://copier-template-tester.kyleking.me/docs/CHANGELOG
[code_tag_summary]: https://copier-template-tester.kyleking.me/docs/CODE_TAG_SUMMARY
[contributor-covenant]: https://www.contributor-covenant.org
[developer_guide]: https://copier-template-tester.kyleking.me/docs/DEVELOPER_GUIDE
[license]: https://github.com/kyleking/copier-template-tester/blob/main/LICENSE
[scripts]: https://github.com/kyleking/copier-template-tester/blob/main/scripts
[style_guide]: https://copier-template-tester.kyleking.me/docs/STYLE_GUIDE
[tests]: https://github.com/kyleking/copier-template-tester/blob/main/tests
Raw data
{
"_id": null,
"home_page": "https://github.com/kyleking/copier-template-tester",
"name": "copier_template_tester",
"maintainer": null,
"docs_url": null,
"requires_python": "<4.0.0,>=3.10.9",
"maintainer_email": null,
"keywords": "calcipy_template",
"author": "Kyle King",
"author_email": "dev.act.kyle@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/37/79/ee40a735d0b3bddb00911a22d502d6cefe8d11d0f20308a600e2861714cc/copier_template_tester-2.1.4.tar.gz",
"platform": null,
"description": "# copier-template-tester\n\n![./ctt-logo.png](./ctt-logo.png)\n\nParametrize copier templates to test for syntax errors, check the expected output, and to check against copier versions.\n\nNote 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.\n\n## Usage\n\n### Configuration File\n\nWhen creating a copier template repository, I recommend following the nested [\"subdirectory\" approach](https://copier.readthedocs.io/en/latest/configuring/#subdirectory) so that the directory looks like this:\n\n```sh\n\u2514\u2500\u2500 template_dir\n\u2502 \u2514\u2500\u2500 {{ _copier_conf.answers_file }}.jinja\n\u251c\u2500\u2500 README.md\n\u251c\u2500\u2500 copier.yml\n\u2514\u2500\u2500 ctt.toml\n```\n\nCreate a new `ctt.toml` file in the top-level directory of your copier repository. Populate the file to look like the below example.\n\n```toml\n# Specify shared data across all 'output' destinations\n# Note that the copier.yml defaults are used whenever the key is not set in this file\n[defaults]\nproject_name = \"placeholder\"\ncopyright_year = 2022\n\n# Parametrize each output with a relative path and optionally any values to override\n[output.\".ctt/defaults\"]\n\n[output.\".ctt/no_all\"]\npackage_name = \"testing-no-all\"\ninclude_all = false\n```\n\n### Pre-Commit Hook\n\nFirst, add this section to your `.pre-commit-config.yml` file:\n\n```yaml\nrepos:\n - repo: https://github.com/KyleKing/copier-template-tester\n rev: main\n hooks:\n - id: copier-template-tester\n```\n\nInstall and update to the latest revision:\n\n```sh\npre-commit autoupdate\n```\n\nThe run with `pre-commit`:\n\n```sh\npre-commit run --all-files copier-template-tester\n```\n\n### pipx\n\nYou can also try `ctt` as a CLI tool by installing with `pipx`:\n\n```sh\npipx install copier-template-tester\n\ncd ~/your/copier/project\nctt\n```\n\n### More Examples\n\nFor more example code, see the [scripts] directory or the [tests].\n\n## Project Status\n\nSee the `Open Issues` and/or the [CODE_TAG_SUMMARY]. For release history, see the [CHANGELOG].\n\n## Contributing\n\nWe 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:\n\n- [DEVELOPER_GUIDE]\n- [STYLE_GUIDE]\n\n## Code of Conduct\n\nWe follow the [Contributor Covenant Code of Conduct][contributor-covenant].\n\n### Open Source Status\n\nWe try to reasonably meet most aspects of the \"OpenSSF scorecard\" from [Open Source Insights](https://deps.dev/pypi/copier-template-tester)\n\n## Responsible Disclosure\n\nIf you have any security issue to report, please contact the project maintainers privately. You can reach us at [dev.act.kyle@gmail.com](mailto:dev.act.kyle@gmail.com).\n\n## License\n\n[LICENSE]\n\n[changelog]: https://copier-template-tester.kyleking.me/docs/CHANGELOG\n[code_tag_summary]: https://copier-template-tester.kyleking.me/docs/CODE_TAG_SUMMARY\n[contributor-covenant]: https://www.contributor-covenant.org\n[developer_guide]: https://copier-template-tester.kyleking.me/docs/DEVELOPER_GUIDE\n[license]: https://github.com/kyleking/copier-template-tester/blob/main/LICENSE\n[scripts]: https://github.com/kyleking/copier-template-tester/blob/main/scripts\n[style_guide]: https://copier-template-tester.kyleking.me/docs/STYLE_GUIDE\n[tests]: https://github.com/kyleking/copier-template-tester/blob/main/tests\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Test copier templates",
"version": "2.1.4",
"project_urls": {
"Bug Tracker": "https://github.com/kyleking/copier-template-tester/issues",
"Changelog": "https://github.com/kyleking/copier-template-tester/blob/main/docs/docs/CHANGELOG.md",
"Documentation": "https://copier-template-tester.kyleking.me",
"Homepage": "https://github.com/kyleking/copier-template-tester",
"Repository": "https://github.com/kyleking/copier-template-tester"
},
"split_keywords": [
"calcipy_template"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "790eecd1bf7ba687d074aa100ea467873432470adabddb777bf51ec60f9850b3",
"md5": "25eb06ec5103208d826a1d035b76b13a",
"sha256": "41f8bb19f1c57de4005f63a1abc24d1720ec1ef9501b7e79dd4a8d22e4bea9c1"
},
"downloads": -1,
"filename": "copier_template_tester-2.1.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "25eb06ec5103208d826a1d035b76b13a",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4.0.0,>=3.10.9",
"size": 10695,
"upload_time": "2024-11-19T12:06:32",
"upload_time_iso_8601": "2024-11-19T12:06:32.893528Z",
"url": "https://files.pythonhosted.org/packages/79/0e/ecd1bf7ba687d074aa100ea467873432470adabddb777bf51ec60f9850b3/copier_template_tester-2.1.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3779ee40a735d0b3bddb00911a22d502d6cefe8d11d0f20308a600e2861714cc",
"md5": "237751b685bc72280f80cd01097c94ec",
"sha256": "1baaa74c81d5d286f508e285e23bc31ea7644ecd47d53dd0161471367ce82162"
},
"downloads": -1,
"filename": "copier_template_tester-2.1.4.tar.gz",
"has_sig": false,
"md5_digest": "237751b685bc72280f80cd01097c94ec",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4.0.0,>=3.10.9",
"size": 9748,
"upload_time": "2024-11-19T12:06:35",
"upload_time_iso_8601": "2024-11-19T12:06:35.152057Z",
"url": "https://files.pythonhosted.org/packages/37/79/ee40a735d0b3bddb00911a22d502d6cefe8d11d0f20308a600e2861714cc/copier_template_tester-2.1.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-11-19 12:06:35",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kyleking",
"github_project": "copier-template-tester",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "copier_template_tester"
}