当前位置: 首页 > 软件库 > 云计算 > 云原生 >

pytest-testinfra

Testinfra test your infrastructures
授权协议 Apache-2.0 License
开发语言 Python
所属分类 云计算、 云原生
软件类型 开源软件
地区 不详
投 递 者 胡俊贤
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

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 ofyour 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 asa plugin to the powerful Pytest test engine

License

Apache License 2.0

The logo is licensed under the Creative Commons NoDerivatives 4.0 LicenseIf 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 ====================
  • Pytest自动化测试 - 必知必会的一些插件 Pytest拥有丰富的插件架构,超过800个以上的外部插件和活跃的社区,在PyPI项目中以“ pytest- *”为标识。 本篇将列举github标星超过两百的一些插件进行实战演示。 插件库地址:http://plugincompat.herokuapp.com/ 1、pytest-html:用于生成HTML报告 一次完整的测试,测试报告是必不可少的

  • 服务器安装ansible 通过设计, Ansible表达了计算机的期望状态,以确保将Ansible剧本或角色的内容部署到目标计算机。 但是,如果您需要确保所有基础架构更改都在Ansible中怎么办? 还是随时验证服务器的状态? Testinfra是基础结构测试框架,可轻松编写单元测试以验证服务器状态。 它是一个Python库,并使用了功能强大的pytest测试引擎。 Testinfra入门 使用P

  • Testinfra 是一个功能强大的库,可用于编写测试来验证基础设施的状态。另外它与 Ansible 和 Nagios 相结合,提供了一个用于架构即代码 (IaC) 的简单解决方案。 Terminal command prompt on orange background 根据设计,Ansible 传递机器的期望状态,以确保 Ansible 剧本或角色的内容部署到目标机器上。但是,如果你需要确保所

 相关资料
  • pytest 是一个功能齐全的 Python 测试工具,可以帮助编写更好的程序,不仅可以编写小测试,还可以扩展到复杂的功能测试。 特性: 有关失败的断言语句的详细信息(无需记住 self.assert* names) 自动发现测试模块和功能 模块化式具,用于管理小型或参数化的长期测试资源 可以开箱即用运行单元测试、Nose 测试套件 Python 3.5+ 与 PyPy3; 丰富的插件架构,拥有

  • pytest_mozwebqa 是一个插件,能够为 py.test 提供 Mozilla 的 WebQA 项目所需的附加功能。 使用条件: py.test selenium requests  

  • pytest-flask An extension of pytest test runner whichprovides a set of useful tools to simplify testing and developmentof the Flask extensions and applications. To view a more detailed list of extensi

  • pytest-flask-sqlalchemy A pytest plugin providing fixtures for running tests intransactions using Flask-SQLAlchemy. Contents Motivation Quick examples Usage Installation From PyPi Development version

  • 我已经在DebianLinux下安装了pytest 2.3.4。默认情况下,它在Python 2.7下运行,但有时我想在Python 3. x下运行它,它也已安装。我似乎找不到任何关于如何做到这一点的说明。 PyPI Trove分类器显示Python:: 3,所以大概是可能的。除了

  • 面对使用覆盖率运行pytest时出现的问题,我已经浏览了SO帖子,但无法解决此问题,我相信我在这里遗漏了一些东西。。 获取以下错误,其中用户是我项目的应用程序 我的测试。ini文件内容 [pytest]DJANGO_设置_模块=cloudstack。设置 python\u文件=测试。py测试*。py*\u测试。py addopts=-v--ignore=venv--cov=--cov报告=html