--- id: testinfra version: "6.0.0" license: unclear license_treatment: permissive maintenance: active --- # testinfra — Test infrastructures License: permissive · Maintenance: active · Downloads: 141.2K/mo ## 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 above — verify before relying. Testinfra lets you write Python unit tests that verify the actual state of servers—checking files, packages, services, and system configuration—as a pytest plugin. 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 pip install testinfra uv add testinfra poetry add testinfra ## Installing testinfra 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. 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 Requires Python 3.5 or later; tests run against actual servers or local system, so the target infrastructure must be accessible. 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: not declared (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 141.2K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags infrastructure testing python, server state verification, pytest infrastructure tests, configuration compliance testing, ansible puppet chef testing, system state assertions, infrastructure as code testing, infrastructure-testing, pytest-plugin, server-validation [View on SkillFed](https://skillfed.io/packages/testinfra) · [View on PyPI](https://pypi.org/project/testinfra/)