In this tutorial we're going to follow the execution flow of pytest to see how it does work. Pytest is highly extendable to the extent that not only its plugins but also its core functionalities are implemented as plugins. Generally, A program and its plugins work in the way that program starts and at some specific steps of its execution, it gives control to the plugins. Those specific steps are called hooks. The program has a registered list of plugins that once program reaches a hook, their corresponding hook implementations are called in a specific order.
For its plugin system, pytest relies on Pluggy. As per Pluggy, program should hold an instance of PluginManager
which is in charge of keeping hook specifications, registering plugins and calling them. Program declares its hooks specification and adds it to the plugin manager. Then plugins can register themselves to the plugin manager.
When a hook is called, its implementations are called in LIFO order, the later