Test infrastructures
Project description
Latest documentation: https://testinfra.readthedocs.io/en/latest
About
With Testinfra you can write unit tests in Python to test actual state of your servers configured by management tools like Salt, Ansible, Puppet, Chef and so on.
Testinfra aims to be a Serverspec equivalent in python and is written as a plugin to the powerful Pytest test engine
License
The logo is licensed under the Creative Commons NoDerivatives 4.0 License If you have some other use in mind, contact us.
Quick start
Install testinfra using pip:
$ pip install pytest-testinfra # or install the devel version $ pip install 'git+https://github.com/pytest-dev/pytest-testinfra@master#egg=pytest-testinfra'
Write your first tests file to test_myinfra.py:
def test_passwd_file(host):
passwd = host.file("/etc/passwd")
assert passwd.contains("root")
assert passwd.user == "root"
assert passwd.group == "root"
assert passwd.mode == 0o644
def test_nginx_is_installed(host):
nginx = host.package("nginx")
assert nginx.is_installed
assert nginx.version.startswith("1.2")
def test_nginx_running_and_enabled(host):
nginx = host.service("nginx")
assert nginx.is_running
assert nginx.is_enabled
And run it:
$ py.test -v test_myinfra.py ====================== test session starts ====================== platform linux -- Python 2.7.3 -- py-1.4.26 -- pytest-2.6.4 plugins: testinfra collected 3 items test_myinfra.py::test_passwd_file[local] PASSED test_myinfra.py::test_nginx_is_installed[local] PASSED test_myinfra.py::test_nginx_running_and_enabled[local] PASSED =================== 3 passed in 0.66 seconds ====================
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file pytest-testinfra-6.7.0.tar.gz
.
File metadata
- Download URL: pytest-testinfra-6.7.0.tar.gz
- Upload date:
- Size: 79.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfde1ce0f1f7cc0dd5c62a29d0f986f3a98a8c144bbcbaebdf7eeeaf16163ec1 |
|
MD5 | f4957d63362ca046d504859ad7034e78 |
|
BLAKE2b-256 | e56a6b458c1bb8a9f8879064de2d98c4ef9ea8d2373785494ff8cbb8096b44e8 |
File details
Details for the file pytest_testinfra-6.7.0-py3-none-any.whl
.
File metadata
- Download URL: pytest_testinfra-6.7.0-py3-none-any.whl
- Upload date:
- Size: 72.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b324210d9ead6554302e5c0b6383b238617577619de2e074f5fed22962b3004c |
|
MD5 | ea1ed5b4881a1496ee0533437ad52748 |
|
BLAKE2b-256 | 936f347981df47fda91623a86eda3d948d8e123beb986ee337f9a31ea2f1fd5d |