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 testinfra # or install the devel version $ pip install 'git+https://github.com/philpep/testinfra@master#egg=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
testinfra-3.0.4.tar.gz
(67.7 kB
view hashes)
Built Distribution
Close
Hashes for testinfra-3.0.4-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1aa8eb26b0578a6c7882088eaeee91960c822d54b149e97d8f9b3ea31f7417a8 |
|
MD5 | 938bba20df5ac1f1ac508910e3c90913 |
|
BLAKE2b-256 | fd2a7af58ab638836c1f20f50ea6c6f7ff6dd7cd08ab77a28beeb3632a6d809f |