tftest
Simple Terraform test helper
What it is and what it does
tftest is a Python wrapper around the Terraform command-line tool designed to simplify testing Terraform modules. It provides a programmatic interface to run Terraform operations (init, plan, apply, destroy) and parse their outputs, making it easier to write unit tests that validate Terraform configurations without manual command execution.
The package supports two testing approaches: lightweight tests using only init and plan to verify syntax and resource counts, or full integration tests that run the complete apply/output/destroy cycle and validate actual infrastructure state. It includes a caching mechanism to speed up repeated test runs by storing and reusing command outputs based on file content hashes, and provides convenience classes to access plan variables, outputs, resources, and modules in a structured way.
Use it for:
- Validate Terraform module syntax and resource definitions in CI/CD pipelines before deployment.
- Test that Terraform configurations produce the expected number and type of resources via plan output inspection.
- Verify Terraform outputs and state file contents after applying configurations to actual infrastructure.
- Cache expensive Terraform operations during test development to reduce iteration time.
- Programmatically inspect plan resources and module structure from Python test code.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Wraps the Terraform executable to facilitate testing Terraform modules from Python unit tests, exposing methods to set up fixtures, execute Terraform commands, and parse their output.
Yes. tftest is actively maintained, has no external runtime dependencies, carries a permissive license, and solves a clear problem for teams testing Terraform infrastructure-as-code. The caching feature and structured output parsing add practical value. Install it if you write Python tests for Terraform modules.
Install
tftest on PyPI
pip
pip install tftestuv
uv add tftestpoetry
poetry add tftestInstalling tftest
Before you install
Low install friction with no runtime dependencies. Actively maintained as of 2026-06-29 with a recent release cycle.
License in practice
Licensed under Apache Software License (permissive), allowing use in commercial and proprietary projects without significant restriction.
Quickstart
pip install tftest
import tftest
tf = tftest.TerraformTest('plan', 'path/to/terraform')
tf.setup()
plan = tf.plan(output=True)
Terraform binary must be installed and available on the system PATH; Terraform 0.12 or later is required.
Verify before relying
- Whether caching feature works reliably across different Terraform versions and file system states.
- Performance characteristics when testing large or complex Terraform modules.
- Compatibility with recent Terraform versions beyond 0.12.
Package facts
| License | not declared (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | actively maintained — 46 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 116,499/month — #12,200 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: tftest-1.8.8-py3-none-any.whl
Tags
More Testing packages
Pluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
virtualenvvirtualenv creates isolated Python environments…
permissive · top 100 on PyPI
coverageCoverage.py measures which lines of Python code…
permissive · top 1,000 on PyPI
pytest-asynciopytest-asyncio is a pytest plugin that enables…
permissive · top 1,000 on PyPI
pytest-json-ctrfA pytest plugin that generates test reports in…
permissive · top 1,000 on PyPI
python-terraformWraps the Terraform command-line tool, allowing…
permissive · top 15,000 on PyPI
tfparsetfparse parses and evaluates Terraform HCL…
permissive · top 15,000 on PyPI
terraform-complianceterraform-compliance is a BDD-based test…
permissive · top 15,000 on PyPI
terraform-localA wrapper script that runs Terraform against…
permissive · top 15,000 on PyPI
executable-applicationA minimal executable application package…
unclear · top 15,000 on PyPI
pytest-dockerpytest-docker provides pytest fixtures that…
permissive · top 5,000 on PyPI
pytest-lazy-fixtureAllows you to use pytest fixtures directly as…
permissive · top 15,000 on PyPI
mocksftpProvides an in-process SFTP server for testing…
permissive · top 15,000 on PyPI
testgrestestgres orchestrates temporary PostgreSQL…
unclear · top 15,000 on PyPI
pytest-lazy-fixturesAllows you to reference pytest fixtures…
permissive · top 5,000 on PyPI