Introduction

Completed

Getting started with testing in Python can be overwhelming. Python's standard library does offer some utilities and helpers to write tests, but has some drawbacks that might make it difficult.

Pytest is one of the most popular testing tools and frameworks for Python. Although Pytest can help with highly complex testing scenarios, it doesn't force its capabilities when creating tests. You can write simple tests and still benefit from the fast and featureful test runner and useful reporting.

A crucial aspect of Pytest is that it makes writing tests easier. You can write a test function with no dependencies or configuration and run the test right away.

Here, we cover some of the basics needed to get started with Pytest so you can take your test suite to the next level.

What you will learn

By the end of this module, you're able to write tests with Pytest, interpret its rich failure reporting, and take advantage of its featureful test runner. You should feel comfortable working with both test functions and classes, and be capable of determining when to use either.

This knowledge allows you to:

  • Work with existing tests for Pytest or extend an existing test suite.
  • Use Pytest's error reporting to accurately determine failures.
  • Use Pytest as a library and a command-line tool.

What is the main goal?

You should feel comfortable working with Pytest and writing tests for Pytest, allowing you to become a more efficient engineer by helping you write more and better tests.