pytest

Breakdown of fixture setup time in py.test


I have some py.test tests that have multiple dependent and parameterized fixtures and I want to measure the time taken by each fixture. However, in the logs with --durations it only shows time for setup for actual tests, but doesn't give me a breakdown of how long each individual fixture took.


Solution

  • There isn't anything builtin for that, but you can easily implement yourself by using the new pytest_fixture_setup() hook in a conftest.py file.