Skip to Content
基于Python的DevOps
book

基于Python的DevOps

by Noah Gift, Kennedy Behrman, Alfredo Deza, Grig Gheorghiu
March 2022
Intermediate to advanced
532 pages
9h 41m
Chinese
China Electric Power Press Ltd.
Content preview from 基于Python的DevOps
218
8
开它了。这个框架的功能非常丰富,以至于任何简略的介绍都不可能像项目的文档
那样完整。
pytest
项目的文档中包含大量信息、示例和功能详解(
https://oreil.ly/
PSAu2
),非常值得一读。随着项目新版的发布和测试方法的改进,总
会有新的知识需要学习。
以前,
Alfredo
每次编写测试都备受折磨,完全不习惯使用
Python
内置的
unittest
(本
章后文将细数两者之间的差异),后来有人向他介绍了
pytest
框架,几分钟之内他
就被
pytest
的魔力吸引住了。
pytest
不强迫他使用自己不习惯的方式编写测试,而
且拿来即用,不用做什么修改。这种灵活性贯穿整个项目,即使有当下看来过时的
东西,也可以通过插件或配置文件扩展功能。
掌握如何写出简洁的测试用例的方法,合理利用命令行工具、报告引擎、插件和实
用程序之后,你便会有意愿编写更多的测试,这对所有人都是一件好事。
8.2 pytest
入门
简单来说,
pytest
是一个命令行工具,用于发现并运行
Python
测试。用户无须了
pytest
的内部机理,很容易上手。本节介绍一些最基本的特性,包括如何正确地
在文件中编写测试(以便让
pytest
发现),以及
pytest
Python
内置的测试框架
unittest
之间的主要区别。
多数集成开发环境(
integrated development environment
IDE
),
PyCharm
Visual Studio Code
,都内置了对
pytest
的支持。如果
你使用
Vim
文本编辑器,可以通过 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

解密金融数据

解密金融数据

Justin Pauley
写给系统管理员的Python脚本编程指南

写给系统管理员的Python脚本编程指南

Posts & Telecom Press, Ganesh Sanjiv Naik
数据科学中的实用统计学(第2版)

数据科学中的实用统计学(第2版)

Peter Bruce, Andrew Bruce, Peter Gedeck

Publisher Resources

ISBN: 9787519864415