测试基础设施

testinfra的Python项目详细描述


最新文档:https://testinfra.readthedocs.io/en/latest

关于

使用testinfra,您可以用python编写单元测试来测试 由管理工具配置的服务器,如SaltAnsiblePuppetChef等等。

testinfra的目标是成为python中的Serverspec等价物,并编写为 强大的Pytest测试引擎的插件

许可证

Apache License 2.0

商标是根据Creative Commons NoDerivatives 4.0 License授权的 如果您有其他用途,请联系我们。

快速启动

使用pip安装testinfra:

$ pip install testinfra

# or install the devel version
$ pip install 'git+https://github.com/philpep/testinfra@master#egg=testinfra'

将第一个测试文件写入test myinfra.py

deftest_passwd_file(host):passwd=host.file("/etc/passwd")assertpasswd.contains("root")assertpasswd.user=="root"assertpasswd.group=="root"assertpasswd.mode==0o644deftest_nginx_is_installed(host):nginx=host.package("nginx")assertnginx.is_installedassertnginx.version.startswith("1.2")deftest_nginx_running_and_enabled(host):nginx=host.service("nginx")assertnginx.is_runningassertnginx.is_enabled

运行它:

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

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
泛型Java将参数约束到公共超类   java Spring引导:在构造函数中加载属性文件并用作autowire注释   java中的优先级队列顺序错误。util。优先级队列和特定比较器   带有Java Sprint引导REST的Google应用程序引擎标准在GCLOUD服务器中不起作用   安卓从Java代码中检索变量并将其作为参数分配给TestNG   用于读取列表值的Java JSON对象   java Hibernate映射:实体映射中的重复列   多线程。start()不从Java中的父线程分派   java Android facebook webdialog网络错误(netstack:lib_mgr错误)   http使用Java阻止网站   java DynamicAsper:访问连接报表中动态列的值   java如何分离文件中的每个单词,并在表中显示每个单词和每个单词的编号?   如何打包和部署EclipseJava应用程序?   java使用Mule Anypoint,我想实现没有flowref的功能   java Kafka consumer ClassNotFoundException   java错误捕获帮助;消息不断重复   javaspring,Thymeleaf和CSS如何给错误着色   javascript如何在java中实现反向ajax   如何通过UDP连接从java数据包中读取序列号?