Introduction

Completed

There’s much more to Pytest beyond the basics of running tests and rich reporting. Although using Pytest as a library isn’t a requirement for running or writing tests, it's useful to understand its capabilities. These Pytest capabilities allow you to write better tests and increase the coverage, while keeping you effective when dealing with failures.

In this module, you'll go through some of the most essential features of the Pytest framework so that you can write powerful tests while keeping them simple and readable.

What you will learn

After completing this module, you'll be able to take advantage of a few features of the Pytest framework to write better tests. You'll find about how parametrizing of tests can reduce code repetition while allowing more and better test coverage. Additionally, you'll get exposed to fixtures, which allows sharing common setups and cleanups in tests.

This will allow you to:

  • Increase code coverage by easily adding more input values using parametrize.
  • Build common test code with fixtures and avoid code repetition.
  • Use code patching to set specific behavior in tests.

What is the main goal

You should feel empowered by leveraging some of the advanced features of Pytest. This will allow you to enhance a test suite or write new, better, and more powerful tests for better coverage and end up with a robust collection of tests.