pytest-testinfra
Test infrastructures
Decision gist · record as of 2026-08-14
Yes, if you manage infrastructure with configuration tools and want to verify actual server state in Python. The single pytest dependency keeps install friction low, and the permissive license poses no barrier. The aging maintenance status (502 days since last release) is a caution: the package is stable but may respond slowly to bugs or new requirements. Suitable for production use in established infrastructure workflows.AI-flagged interpretation of the facts on this page — verify before relying
Before you install
- Requires Python 3.9 or later.
- Tests must run on or have network access to the target servers being inspected.
- Low friction: a single runtime dependency on pytest, distributed as a wheel.
License · maintenance · safety
permissive license (permissive) — Apache License 2.0 (permissive). You can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
last release 2025-03-30 (502 days)
0 known vulnerabilities (OSV.dev, 2026-08-14) · 1,545,408 downloads/mo, #3,779 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 package supports all major configuration management tools (Salt, Ansible, Puppet, Chef) equally or has gaps in any.
- Current maintenance activity and responsiveness to bug reports, given the 502-day gap since last release.
- Whether remote testing over SSH or other protocols is fully documented and production-ready.
What it is and what it does
Pytest-testinfra is a pytest plugin that brings infrastructure testing into Python. Instead of writing shell scripts or separate test frameworks to verify server configuration, you write pytest test functions that inspect the actual state of your infrastructure—checking whether files exist with the right permissions, packages are installed, services are running, users have correct groups, and so on. It acts as a Python equivalent to Serverspec, integrating directly with pytest's test runner and reporting.
You typically use it after provisioning servers with tools like Ansible, Puppet, Chef, or Salt to verify that the configuration management actually produced the desired state. The package provides a `host` fixture that abstracts away the details of connecting to and querying target machines, so your tests read like straightforward assertions rather than shell command chains.
Use it for
- Verify that Ansible playbooks or Puppet manifests correctly installed packages and configured services on target servers.
- Assert file permissions, ownership, and content match infrastructure-as-code specifications after deployment.
- Check that running services are enabled and listening on expected ports after configuration management runs.
- Test user and group creation, membership, and home directory setup across a fleet of servers.
- Validate system state in CI/CD pipelines after infrastructure provisioning to catch configuration drift early.
Worth the install?
AI-flagged interpretation of the facts on this page. Verify before relying on it.
Yes, if you manage infrastructure with configuration tools and want to verify actual server state in Python.
The single pytest dependency keeps install friction low, and the permissive license poses no barrier. The aging maintenance status (502 days since last release) is a caution: the package is stable but may respond slowly to bugs or new requirements. Suitable for production use in established infrastructure workflows.
Install
pytest-testinfra on PyPI
Before you install
Low friction: a single runtime dependency on pytest, distributed as a wheel. Maintenance status is aging—last release was 502 days ago—so expect slower response to issues, though the package is marked Production/Stable.
Requires Python 3.9 or later. Tests must run on or have network access to the target servers being inspected.
License in practice
Apache License 2.0 (permissive). You can use, modify, and distribute this package freely in commercial and private projects with minimal restrictions.
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 package supports all major configuration management tools (Salt, Ansible, Puppet, Chef) equally or has gaps in any.
- Current maintenance activity and responsiveness to bug reports, given the 502-day gap since last release.
- Whether remote testing over SSH or other protocols is fully documented and production-ready.
Package facts
| License | permissive license permissive |
| Python support | Supports the current Python release >=3.9 |
| Install friction | Low. Pure-Python wheel |
| Runtime dependencies | 1 packagepytest |
| Maintenance | Aging 502 days since the last release |
| First released | |
| Downloads | 1,545,408 / month, #3,779 on PyPI 30-day window, as of 2026-08-14 |
| Known vulnerabilities | None known OSV.dev, checked 2026-08-14 |
| Classifiers | Development Status :: 5 - Production/StableEnvironment :: 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.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.9Topic :: Software Development :: TestingTopic :: System :: Systems Administration |
Evidence: pytest_testinfra-10.2.2-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 › “infrastructure testing python”
- pytest-testinfraA pytest plugin that lets you write Python unit tests to verify the…
- testinfraTestinfra lets you write Python unit tests that verify the actual…
- molecule-pluginsProvides driver plugins for molecule that enable testing across…
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 testinfra · pytest-container · pytest-ansible · tox-ansible · pytest-selenium · pytest-instafail · pytest-base-url · pytest-isort · molecule-docker