Description
In my project, I had a pytest_generate_tests
function in one of my test files (not conftest.py) and it worked great. I wanted to add more hooks like pytest_terminal_summary
so I added them right next to my pytest_generate_tests
, without making a separate plugin or using conftest.py.
But even though pytest_generate_tests
worked fine, none of my other hook attempts were detected.
After being confused for a while, I looked at the pytest source and learned that pytest
uses a special pluggy
feature called call_extra
for pytest_generate_tests
and nothing else! So there is exactly one hook that you can use directly in your test files without putting it in conftest.py
.
I have no opinion about whether this special case is a good choice for pytest
or not, but as far as I can tell it's completely undocumented. I'm not sure the best place to put documentation of this: at the very least, in the reference page defining pytest_generate_tests
, and maybe somewhere in writing_hook_tests.rst
?