Testing Python code with pytest

Length: 1 day

Description: From individual hobbyists to the largest corporations, just about everyone agrees that it’s important to test your code. But which testing framework should you use? In the Python world, “pytest” has rocketed to popularity in the last few years — largely because of how easy it is to use and integrate into your software-testing framework.

This course introduces “pytest”, from installation and configuration, through common things you might want to test, to repeating tests, to mocking, fixtures, and other advanced topics. By the end of this day, your developers will not only understand how to test code with pytest, but how to write code that works well with pytest, and is thus more maintainable

Audience: Python developers who are familiar with basic Python data types, writing functions, and using modules have enough background to take this course.


  • Installing pytest
  • Testing functions and classes
  • Simple and complex assertions
  • Testing for exceptions
  • Code coverage
  • Parametrized tests
  • Built-in fixtures
  • Simulating input, capturing output
  • Writing your own fixtures
  • Working with files, temp files, and file-like objects
  • Good pytest style
  • Configuration files and command-line arguments
  • Add-ons for pytest