pytest-dev / pytest-asyncio

Asyncio support for pytest
https://pytest-asyncio.readthedocs.io
Apache License 2.0
1.43k stars 152 forks source link

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

Open cdleonard opened 8 months ago

cdleonard commented 8 months ago

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.

isra17 commented 7 months ago

I have the same error in one of my project.