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

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

Open cdleonard opened this issue 1 year ago • 1 comments

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.

cdleonard avatar Mar 08 '24 11:03 cdleonard

I have the same error in one of my project.

isra17 avatar Apr 09 '24 14:04 isra17

No longer reproducibel in v1.0.0a1 and should be fixed as part of the v1.0.0 release.

seifertm avatar May 26 '25 04:05 seifertm