pytest-testinfra


Namepytest-testinfra JSON
Version 10.1.1 PyPI version JSON
download
home_pagehttps://github.com/pytest-dev/pytest-testinfra
SummaryTest infrastructures
upload_time2024-05-26 16:54:04
maintainerNone
docs_urlNone
authorPhilippe Pepiot
requires_python>=3.9
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            ##################################
Testinfra test your infrastructure
##################################

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
=======

`Apache License 2.0 <https://github.com/pytest-dev/pytest-testinfra/blob/main/LICENSE>`_

The logo is licensed under the `Creative Commons NoDerivatives 4.0 License <https://creativecommons.org/licenses/by-nd/4.0/>`_
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@main#egg=pytest-testinfra'


Write your first tests file to `test_myinfra.py`:

.. code-block:: python

    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 ====================


.. _Salt: https://saltstack.com/
.. _Ansible: https://www.ansible.com/
.. _Puppet: https://puppetlabs.com/
.. _Chef: https://www.chef.io/
.. _Serverspec: https://serverspec.org/
.. _Pytest: https://pytest.org/

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/pytest-dev/pytest-testinfra",
    "name": "pytest-testinfra",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Philippe Pepiot",
    "author_email": "phil@philpep.org",
    "download_url": "https://files.pythonhosted.org/packages/53/15/354adf3dd9635b554b27eb0167216e02bebed1796035991999c32b5081af/pytest-testinfra-10.1.1.tar.gz",
    "platform": null,
    "description": "##################################\nTestinfra test your infrastructure\n##################################\n\nLatest documentation: https://testinfra.readthedocs.io/en/latest\n\nAbout\n=====\n\nWith Testinfra you can write unit tests in Python to test *actual state* of\nyour servers configured by management tools like Salt_, Ansible_, Puppet_,\nChef_ and so on.\n\nTestinfra aims to be a Serverspec_ equivalent in python and is written as\na plugin to the powerful Pytest_ test engine\n\nLicense\n=======\n\n`Apache License 2.0 <https://github.com/pytest-dev/pytest-testinfra/blob/main/LICENSE>`_\n\nThe logo is licensed under the `Creative Commons NoDerivatives 4.0 License <https://creativecommons.org/licenses/by-nd/4.0/>`_\nIf you have some other use in mind, contact us.\n\nQuick start\n===========\n\nInstall testinfra using pip::\n\n    $ pip install pytest-testinfra\n\n    # or install the devel version\n    $ pip install 'git+https://github.com/pytest-dev/pytest-testinfra@main#egg=pytest-testinfra'\n\n\nWrite your first tests file to `test_myinfra.py`:\n\n.. code-block:: python\n\n    def test_passwd_file(host):\n        passwd = host.file(\"/etc/passwd\")\n        assert passwd.contains(\"root\")\n        assert passwd.user == \"root\"\n        assert passwd.group == \"root\"\n        assert passwd.mode == 0o644\n\n\n    def test_nginx_is_installed(host):\n        nginx = host.package(\"nginx\")\n        assert nginx.is_installed\n        assert nginx.version.startswith(\"1.2\")\n\n\n    def test_nginx_running_and_enabled(host):\n        nginx = host.service(\"nginx\")\n        assert nginx.is_running\n        assert nginx.is_enabled\n\n\nAnd run it::\n\n    $ py.test -v test_myinfra.py\n\n\n    ====================== test session starts ======================\n    platform linux -- Python 2.7.3 -- py-1.4.26 -- pytest-2.6.4\n    plugins: testinfra\n    collected 3 items\n\n    test_myinfra.py::test_passwd_file[local] PASSED\n    test_myinfra.py::test_nginx_is_installed[local] PASSED\n    test_myinfra.py::test_nginx_running_and_enabled[local] PASSED\n\n    =================== 3 passed in 0.66 seconds ====================\n\n\n.. _Salt: https://saltstack.com/\n.. _Ansible: https://www.ansible.com/\n.. _Puppet: https://puppetlabs.com/\n.. _Chef: https://www.chef.io/\n.. _Serverspec: https://serverspec.org/\n.. _Pytest: https://pytest.org/\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Test infrastructures",
    "version": "10.1.1",
    "project_urls": {
        "Homepage": "https://github.com/pytest-dev/pytest-testinfra"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6ba8e66b4ef547c8ff86b9c3a4744c296b879a2c6e98f4796f4bee66b911762b",
                "md5": "90207bb8ea36fa787b7622da1ebb1647",
                "sha256": "b990dc7d77b49a1bba24818fbff49b6171d8c46d606fb5ca86b937de690d7062"
            },
            "downloads": -1,
            "filename": "pytest_testinfra-10.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "90207bb8ea36fa787b7622da1ebb1647",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 76765,
            "upload_time": "2024-05-26T16:54:01",
            "upload_time_iso_8601": "2024-05-26T16:54:01.896903Z",
            "url": "https://files.pythonhosted.org/packages/6b/a8/e66b4ef547c8ff86b9c3a4744c296b879a2c6e98f4796f4bee66b911762b/pytest_testinfra-10.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5315354adf3dd9635b554b27eb0167216e02bebed1796035991999c32b5081af",
                "md5": "72454646846a0f9a798ffb8440bc9953",
                "sha256": "a876f1453a01b58d94d9d936dd50344c2c01ac7880a2b41d15bdf233aed9cf1f"
            },
            "downloads": -1,
            "filename": "pytest-testinfra-10.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "72454646846a0f9a798ffb8440bc9953",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 86567,
            "upload_time": "2024-05-26T16:54:04",
            "upload_time_iso_8601": "2024-05-26T16:54:04.003463Z",
            "url": "https://files.pythonhosted.org/packages/53/15/354adf3dd9635b554b27eb0167216e02bebed1796035991999c32b5081af/pytest-testinfra-10.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-26 16:54:04",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "pytest-dev",
    "github_project": "pytest-testinfra",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "pytest-testinfra"
}
        
Elapsed time: 0.37005s