Skip to content

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

Closed

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.

Activity

  1. added this to the v1.0 milestone on Mar 8, 2024
  2. leameow commented on Apr 9, 2024

    @leameow

    I have the same error in one of my project.

  3. seifertm commented on May 26, 2025

    @seifertm
    Contributor

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions