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.
0:03 But if something is not there,
0:05 there is a huge chance that there is a plugin that you can use.
0:09 There is the website called pytest plugins compatibility that gathers all the projects from pypi
0:14 that matches the pytest-in the name,
0:18 which are considered pytest plugins, so you can see there are over 800 plugins
0:23 but a lot of them are no longer maintained.
0:26 There are version 0.1 and they don't even support python 3.6.
0:31 But there are still plenty of very useful plugins,
0:34 and in the next lesson, I will show you some of them.
0:38 To add other plugin to pytest. You need to install it in the same virtual environment
0:41 as pytest is installed. So let me show you how to add a plugin.
0:46 I found the silly pytest plugin called pytest-emoji that basically adds emoji to the
0:52 test reports. So let's copy this.
0:59 Here I have the pytest chapter virtual environment with pytest installed.
1:04 Go to add our plugin, we have to install it in the same environment,
1:08 and now we can run pytest with the --emoji flag.
1:12 So let's see how the output looks without the flag.
1:18 I still have this one test failing because I'm using lower case foo, while my test
1:23 is expecting uppercase foo. And what happens if we run it with emoji flag?
1:30 Tadah, the boring docs has been changed to emojis.
1:34 Well, it's a funny plugin.
1:36 It's not the most useful one,
1:38 so let's actually check out the useful plugins for pytest.