Pytest Basics
Overview
I recently had to help some clients learn the basics of Pytest, and in order to do so I obviously had to learn Pytest first myself. This is just to capture some of the basics, some examples, and some recommendations and references acquired as part of the process.
Recommendations
If there’s one primary recommendation, it would be to buy and read Python Testing with pytest, Second Edition by Brian Okken.
For UK readers: hive.co.uk - Python Testing with pytest : Simple, Rapid, Effective, and Scalable.
I’ll include a number of other useful online resources, but the Python Testing with pytest book will save most people the time spent piecing together and digesting these into a single, well-paced learning experience.
Examples
References
The core docs for Pytest are very good but often a primer / how-to helps, the resources below have all helped clarify many of the aspects of Pytest.
Pytest Core Docs
Pytest Getting Started Guides
- Pytest Get Started
- Pytest with Eric
- A Beginner’s Guide to Unit Testing with Pytest
- Effective Python Testing With Pytest
- A Complete Guide on How to Test Python Applications with Pytest
- Testing in Python
Pytest Beyond Basics
- Python Testing 101 (How To Decide What To Test)
- Python Unit Testing Best Practices For Building Reliable Applications
Pytest Corner Cases
- Testing your python package as installed
- What Is the Difference Between Invoking
pytest
andpython -m pytest