Skip to content

Conversation

@jeertmans
Copy link
Contributor

Hello!

This comes a bit out of nowhere, but I had this bug for a long time where running pytest on specific paths (instead of the plain pytest command) would raise an error because my package would already be imported, before the import hook could be run.

After some research, I found that the issue originates from my contest.py files, which import the package under test to create fixtures.

Apparently, this issue can be fixed by changing how your plugin is run, i.e., by evaluating it during the initial phase. I looked at other projects, and this seems to be a common practice.

Here is a small patch for this purpose :-)

You can verify that it works by adding import equinox to equinox/tests/conftest.py and then running pytest.

@patrick-kidger patrick-kidger merged commit 9be8523 into patrick-kidger:main Jan 15, 2026
2 checks passed
@patrick-kidger
Copy link
Owner

LGTM! Thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants