skillfed

tftest

Simple Terraform test helper

tftest v1.8.8 116.5K downloads/30d#12,200 on PyPI223
Permissive license Active released

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 tftest

uv

uv add tftest

poetry

poetry add tftest

Installing 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

License :: OSI Approved :: Apache Software LicenseOperating System :: OS IndependentProgramming Language :: Python :: 3

Tags

terraform testing pythonterraform unit test helperterraform plan output parsingterraform module testingterraform apply test frameworkterraform state testing pythonterraform fixture setup
terraforminfrastructure-as-codetesting

More Testing packages