Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not compatible with --doctest-modules --doctest-ignore-import-errors #797

Open
cdleonard opened this issue Mar 8, 2024 · 1 comment
Open
Labels
Milestone

Comments

@cdleonard
Copy link

By default pytest does not import all modules so it is fine if they have import errors due to optional dependencies.

You can cause pytest to import all modules if you pass --doctest-modules. If some of your modules fail to import you will get collection failures

You can make pytest ignore those import errors using --doctest-ignore-import-errors.

This last point is apparently broken if pytest-asyncio is installed (it doesn't even have to be used). This doesn't make any sense to me but maybe the plugin interacts with pytest import logic in some way

I found this in an a larger codebase but was able to reproduce with a minimal gist repo. The test repo tries to run pytest --collect in two minimal containers based on python-alpine: one with pytest only and one with pytest-asyncio as well. The second run shows import errors.

@seifertm seifertm added the bug label Mar 8, 2024
@seifertm seifertm added this to the v1.0 milestone Mar 8, 2024
@isra17
Copy link

isra17 commented Apr 9, 2024

I have the same error in one of my project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants