I’m working on a book focused on pytest.
If you write Python code, you know that you can express your ideas better in high level languages like Python than in low level languages. You want your software tests to be just as expressive, just as elegant, just as readable. This book shows you how. The pytest framework is designed to help you write tests faster, to keep them readable and maintainable, with no boilerplate code. The pytest framework makes it easy to write small tests, yet scales to support complex functional testing for applications, packages and libraries.
This book will teach you how to start writing tests quickly, and how to add powerful testing features when you need them.
- Use Python’s built in assert statement to control test failures.
- Test error conditions and corner cases with expected exception testing.
- Use one test to run many test cases with parameterized testing.
- Move setup code into fixtures, and speed up test times by optimizing setup that can be shared across multiple tests.
- Speed up test times by distributing tests across multiple processors and running tests in parallel.
- Find parts of your code that are under tested with pytest and coverage.
- Make sure your package runs against multiple versions of Python with pytest and tox.
- Extend pytest to work just right for your project using built in and third party plugins.
- Connect pytest to continuous integration systems.
After reading this book, you will be able to:
- Write short, maintainable tests that elegantly express what you are testing and why.
- Use test fixtures for setup code, and reduce false test failures by separating setup failures from test failures.
- Run parts of your test suite: the slowest 10 tests, the tests that failed last time, just the tests that you marked with a particular label, tests with names that match a pattern, just those in a directory|module|class
- Write maintainable, elegant, expressive tests.
The examples in this book are written using Python 3.6 and pytest 3.0. However, pytest 3.0 supports Python 2.6, 2.7 and Python 3.3 – 3.6.
Here 8 are ways to find out when I have more information.
- Listen to the Test & Code Podcast
- Listen to the Python Bytes Podcast
- Subscribe to my very non-spammy email list
- Join the slack channel
- Become a patreon supporter of Test & Code
- Follow @testpodcast or @brianokken on Twitter.
- Buy a copy of my current eBook on pytest, unittest, and nose on gumroad.
- I’ll share more right here also, when I have something to share.