pytest-trio icon indicating copy to clipboard operation
pytest-trio copied to clipboard

Enable Trio Mode through import * doesn't work when using same pytest hooks

Open jordanlibrande opened this issue 1 year ago • 0 comments

from pytest_trio.enable_trio_mode import * doesn't work properly if your conftest.py itself implements pytest_collection_modifyitems or pytest_fixture_setup hooks. It seems the hooks from pytest_trio get shadowed by your local function so the pytest_trio hooks no longer get found and called by pytest.

Maybe at least add this behavior (and a recommended workaround) to the documentation?

I unblocked by having my local hooks call the pytest_trio versions of these hooks internally. (Possibly pytest hookwrapper could also be used?)

Probably better would be to have pytest_trio's pytest_collection_modifyitems and pytest_fixture_setup be in the main pytest_trio plugin, and have their behavior be configurable? Then I think they'll always be collected by pytest.

jordanlibrande avatar Jan 22 '24 22:01 jordanlibrande