Search⌘ K

The pytest Framework

Explore how to leverage the pytest framework to write clean and efficient unit tests in Python. Understand its simple syntax with assert statements, compatibility with unittest, and methods for testing exceptions, improving your testing workflow and code quality.

We'll cover the following...

One great testing framework is pytest, which can be installed via pip install pytest. One difference with respect to unittest is that, while it's still possible to classify test scenarios in classes and create object-oriented models of our tests, this is not actually mandatory, and it's possible to write unit tests with less boilerplate by just checking the conditions we want to verify in simple functions with the assert ...