Skip to content

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

Open
@cdleonard

Description

@cdleonard

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions