Exercises

In ch4/cache/test_slower.py, there is an autouse fixture called check_duration(). You used it in the Chapter 4 exercises as well. Now, let’s make a plugin out of it.

  1. Create a directory named pytest-slower that will hold the code for the new plugin, similar to the directory described in Creating an Installable Plugin.
  2. Fill out all the files of the directory to make pytest-slower an installable plugin.
  3. Write some test code for the plugin.
  4. Take a look at the Python Package Index[18] and search for “pytest-.” Find a pytest plugin that looks interesting to you.
  5. Install the plugin you chose and try it out on Tasks tests.

Get Python Testing with pytest now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.