pytest Quick Start Guide: Write better Python code with simple and maintainable tests
暫譯: pytest 快速入門指南:用簡單且可維護的測試撰寫更好的 Python 代碼
Bruno Oliveira
- 出版商: Packt Publishing
- 出版日期: 2018-08-30
- 售價: $1,450
- 貴賓價: 9.5 折 $1,378
- 語言: 英文
- 頁數: 160
- 裝訂: Paperback
- ISBN: 1789347564
- ISBN-13: 9781789347562
-
相關分類:
Python、程式語言
海外代購書籍(需單獨結帳)
相關主題
商品描述
Learn the pytest way to write simple tests which can also be used to write complex tests
Key Features
- Become proficient with pytest from day one by solving real-world testing problems
- Use pytest to write tests more efficiently
- Scale from simple to complex and functional testing
Book Description
Python's standard unittest module is based on the xUnit family of frameworks, which has its origins in Smalltalk and Java, and tends to be verbose to use and not easily extensible.The pytest framework on the other hand is very simple to get started, but powerful enough to cover complex testing integration scenarios, being considered by many the true Pythonic approach to testing in Python.
In this book, you will learn how to get started right away and get the most out of pytest in your daily work?ow, exploring powerful mechanisms and plugins to facilitate many common testing tasks. You will also see how to use pytest in existing unittest-based test suites and will learn some tricks to make the jump to a pytest-style test suite quickly and easily.
What you will learn
- Write and run simple and complex tests
- Organize tests in fles and directories
- Find out how to be more productive on the command line
- Markers and how to skip, xfail and parametrize tests
- Explore fxtures and techniques to use them effectively, such as tmpdir, pytestconfg, and monkeypatch
- Convert unittest suites to pytest using little-known techniques
- Use third-party plugins
Who this book is for
This book is for Python programmers that want to learn more about testing. This book is also for QA testers, and those who already benefit from programming with tests daily but want to improve their existing testing tools.
Table of Contents
- Introducing pytest
- Writing and running tests
- Markers and parametrization
- Fixtures
- Plugins
- Converting unittest suites to pytest
- Wrappin up
商品描述(中文翻譯)
學習 pytest 的方式來編寫簡單的測試,這些測試也可以用來編寫複雜的測試
主要特點
- 從第一天起就通過解決真實世界的測試問題來熟練掌握 pytest
- 使用 pytest 更有效率地編寫測試
- 從簡單的測試擴展到複雜和功能性測試
書籍描述
Python 的標準 unittest 模組基於 xUnit 系列框架,這些框架源於 Smalltalk 和 Java,使用起來往往冗長且不易擴展。另一方面,pytest 框架非常容易上手,但足夠強大以涵蓋複雜的測試整合場景,許多人認為這是 Python 中真正的 Pythonic 測試方法。
在本書中,您將學習如何立即開始並在日常工作流程中充分利用 pytest,探索強大的機制和插件以便於許多常見的測試任務。您還將看到如何在現有的基於 unittest 的測試套件中使用 pytest,並學習一些技巧以快速輕鬆地轉向 pytest 風格的測試套件。
您將學習的內容
- 編寫和運行簡單及複雜的測試
- 在檔案和目錄中組織測試
- 瞭解如何在命令行上提高生產力
- 標記和如何跳過、標記為失敗(xfail)及參數化測試
- 探索 fixtures 及有效使用它們的技術,例如 tmpdir、pytestconfg 和 monkeypatch
- 使用不太知名的技術將 unittest 套件轉換為 pytest
- 使用第三方插件
本書適合誰
本書適合希望深入了解測試的 Python 程式設計師。本書也適合 QA 測試人員,以及那些每天都從編寫測試中受益但希望改善現有測試工具的人。
目錄
1. 介紹 pytest
2. 編寫和運行測試
3. 標記和參數化
4. Fixtures
5. 插件
6. 將 unittest 套件轉換為 pytest
7. 總結