testinfra
Test infrastructures
Decision gist · record as of 2026-08-14
Yes, if you need to test infrastructure state and can accept the maintenance risk. The package is stable and has no known vulnerabilities, but the lack of active maintenance means you may need to fork or patch it yourself if issues arise. It's well-suited for teams already using pytest and infrastructure-as-code tools, but consider whether a maintained alternative better fits your long-term needs.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.5 or later; tests run against actual servers or local system, so the target infrastructure must be accessible.
- Low friction install with a single runtime dependency (pytest).
- However, the project is not actively maintained; the latest release was over 5 years ago, and the description explicitly warns that issue and pull request responses may be delayed for several months.
License · maintenance · safety
permissive license (permissive) — Licensed under Apache License 2.0 (permissive), so you can use it freely in commercial and open-source projects without restrictive obligations.
last release 2020-11-12 (2101 days) · last repo commit 2026-07-20 · 2,478 stars
0 known vulnerabilities (OSV.dev, 2026-08-14) · 141,218 downloads/mo, #11,245 on PyPI
Alternatives
Verify before relying
pip install pytest-testinfra
# In test_myinfra.py:
def test_passwd_file(host):
passwd = host.file("/etc/passwd")
assert passwd.contains("root")
assert passwd.user == "root"
pytest -v test_myinfra.py- Whether the project accepts and merges community pull requests despite the maintenance notice.
- Current compatibility with modern versions of pytest and Python 3.9+.
- Whether there are maintained forks or alternative projects that provide similar functionality.
What it is and what it does
Testinfra is a pytest plugin that lets you write Python unit tests to verify the actual state of servers and infrastructure. Instead of testing code in isolation, you write assertions about real system state—whether files exist with the right permissions, packages are installed, services are running, and configuration is correct. It's designed as a Python equivalent to Serverspec and works with infrastructure-as-code tools like Ansible, Puppet, Chef, and Salt.
You write tests using a `host` fixture that provides methods to inspect files, packages, services, users, and other system resources. Tests run through pytest, so you get all the standard pytest features and reporting. The project is currently not actively maintained, with the latest release over 5 years old and a maintenance notice warning that responses to issues may be delayed for several months.
Use it for
- Verify that Ansible or Puppet playbooks correctly configured servers after deployment.
- Test that required packages are installed and services are running on production systems.
- Check file permissions, ownership, and content match infrastructure requirements.
- Validate system configuration (users, groups, network settings) in automated pipelines.
- Ensure compliance with security baselines by asserting expected system state.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you need to test infrastructure state and can accept the maintenance risk.
The package is stable and has no known vulnerabilities, but the lack of active maintenance means you may need to fork or patch it yourself if issues arise. It's well-suited for teams already using pytest and infrastructure-as-code tools, but consider whether a maintained alternative better fits your long-term needs.
Install
testinfra on PyPI
Before you install
Low friction install with a single runtime dependency (pytest). However, the project is not actively maintained; the latest release was over 5 years ago, and the description explicitly warns that issue and pull request responses may be delayed for several months.
Requires Python 3.5 or later; tests run against actual servers or local system, so the target infrastructure must be accessible.
License in practice
Licensed under Apache License 2.0 (permissive), so you can use it freely in commercial and open-source projects without restrictive obligations.
Quickstart
pip install pytest-testinfra
# In test_myinfra.py:
def test_passwd_file(host):
passwd = host.file("/etc/passwd")
assert passwd.contains("root")
assert passwd.user == "root"
pytest -v test_myinfra.py
Verify before relying
- Whether the project accepts and merges community pull requests despite the maintenance notice.
- Current compatibility with modern versions of pytest and Python 3.9+.
- Whether there are maintained forks or alternative projects that provide similar functionality.
Package facts
| License | permissive license permissive |
| Python support | Supports the current Python release >=3.5 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagepytest-testinfra |
| Maintenance | Actively maintained 2,101 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 141,218 / month, #11,245 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 7 - InactiveEnvironment :: ConsoleFramework :: PytestIntended Audience :: DevelopersIntended Audience :: Information TechnologyIntended Audience :: System AdministratorsLicense :: OSI Approved :: Apache Software LicenseOperating System :: POSIXProgramming Language :: PythonProgramming Language :: Python :: 3Programming Language :: Python :: 3 :: OnlyProgramming Language :: Python :: 3.6Programming Language :: Python :: 3.7Programming Language :: Python :: 3.8Topic :: Software Development :: TestingTopic :: System :: Systems Administration |
Evidence: testinfra-6.0.0-py3-none-any.whl
Tags
Let your AI agent find packages like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 14,416 PyPI packages by what they can do, searchable in plain language.
wish › “pytest infrastructure tests”
- testinfraTestinfra lets you write Python unit tests that verify the actual…
- pytest-testinfraA pytest plugin that lets you write Python unit tests to verify the…
- pytest-djangopytest-django integrates Django with pytest, letting you write and…
Give your agent the search over MCP, or paste the wish link into any chat.
More Testing packages
Pluggy provides a plugin system that lets you define hook specifications and register implementations to be called in sequence, enabling extensible Python applications without tight coupling.
Install it if you're building an extensible application or framework.
pytest is a testing framework that lets you write test functions using plain assert statements and automatically discovers and runs them, with detailed failure reporting.
virtualenv creates isolated Python environments where packages can be installed independently without affecting the system Python or other projects.
Coverage.py measures which lines of Python code are executed during test runs, reporting coverage percentages and identifying untested code paths.
Install it if you want to measure test completeness or enforce coverage thresholds in your project.
pytest-asyncio is a pytest plugin that enables writing and running async test functions using the asyncio library, allowing developers to await code directly within test cases.
Install it if you write tests for any asyncio-based code.
A pytest plugin that generates test reports in Common Test Report Format (CTRF) as JSON, compatible with pytest-xdist and pytest-playwright for distributed and browser-based testing.
Install it if you need CTRF-formatted test output for CI/CD integration or cross-tool reporting.
See also pytest-testinfra · pytest-container · pytest-ansible · tox-ansible · pytest-instafail · pytest-selenium · molecule-docker · molecule · pytest-isort