Modern Python Projects Transcripts
Chapter: Testing code
Lecture: Extending pytest with plugins

Login or purchase this course to watch this video and the rest of the course contents.
0:00 We saw that pytest offers a lot of functionality out of the box. But if something is not there,
0:06 there is a huge chance that there is a plugin that you can use.
0:10 There is the website called pytest plugins compatibility that gathers all the projects from pypi that matches the pytest-in the name,
0:19 which are considered pytest plugins, so you can see there are over 800 plugins but a lot of them are no longer maintained.
0:27 There are version 0.1 and they don't even support Python 3.6. But there are still plenty of very useful plugins,
0:35 and in the next lesson, I will show you some of them. To add other plugin to pytest. You need to install it in the same virtual environment
0:42 as pytest is installed. So let me show you how to add a plugin. I found the silly pytest plugin called pytest-emoji that basically adds emoji to the
0:53 test reports. So let's copy this. Here I have the pytest chapter virtual environment with pytest installed.
1:05 Go to add our plugin, we have to install it in the same environment, and now we can run pytest with the --emoji flag.
1:13 So let's see how the output looks without the flag. I still have this one test failing because I'm using lower case foo, while my test
1:24 is expecting uppercase foo. And what happens if we run it with emoji flag? Tadah, the boring docs has been changed to emojis.
1:35 Well, it's a funny plugin. It's not the most useful one, so let's actually check out the useful plugins for pytest.


Talk Python's Mastodon Michael Kennedy's Mastodon