Testing Your Code With pytest (Overview)
Testing your code brings a wide variety of benefits. It increases your confidence that the code behaves as you expect and ensures that changes to your code won’t cause regressions. Writing and maintaining tests is hard work, so you should leverage all the tools at your disposal to make it as painless as possible. pytest is one of the best tools you can use to boost your testing productivity.
In this video course, you’ll learn:
- What benefits pytest offers
- How to ensure your tests are stateless
- How to make repetitious tests more comprehensible
- How to run subsets of tests by name or custom groups
- How to create and maintain reusable testing utilities
00:00 Welcome to Testing Your Code With pytest. My name is Christopher, and I will be your guide. This course is all about the third-party testing library pytest.
00:11 You’ll be learning about how to write tests the pytest way, using fixtures to manage test data, dynamically over-writing what code is run through monkey patches, and writing tests that can be reused through the use of parameters.
00:27 The code in this course was tested out with Python 3.10 and pytest 7.1.1. There isn’t anything version specific in here. You should be good with anything relatively recent.
00:40
pytest is a popular third-party library used to write and manage your test suites. You use it instead of the standard library unittest
suite equivalent.
00:50
Its biggest advantage is brevity. It takes less code to write a pytest test function than the unittest
library equivalent. And it has some interesting techniques for reusing your tests and managing test data.
Become a Member to join the conversation.