Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Addopt --import-mode=importlib for pytest to prevent errors with importlib.metadata#203

Merged
abravalheri merged 2 commits into
mainfrom
issue-200
Sep 23, 2024
Merged

Addopt --import-mode=importlib for pytest to prevent errors with importlib.metadata#203
abravalheri merged 2 commits into
mainfrom
issue-200

Conversation

@abravalheri
Copy link
Copy Markdown
Owner

@abravalheri abravalheri commented Sep 17, 2024

Closes #200
Possibly obviates #201

The key aspect for the solution seems to be a pytest update and using importlib mode.

Comment thread pyproject.toml Outdated
--strict-markers
--verbose
"""
norecursedirs = ["dist", "build", ".tox"]
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably having both norecursedirs and testpaths is redundant... (Note however that norecursedirs would give a wider selection of files to test (including for example docs).

docs/conf.py may be dangerous to evaluate as it adds the src folder to sys.path and as established in #200 that causes problems with importlib.metadata.

So we probably just want to remove norecursedirs in a follow-up PR.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I don’t believe they are redundant, because you can manually pass in testpaths. That setting is just a default, while this one makes sure that things that might contain tests (like virtual environments) never get picked up.

@abravalheri
Copy link
Copy Markdown
Owner Author

The macos error is related to a different problem with the recent change in how artifacts are cached in Cirrus CI and should be fixed in a different PR.

@abravalheri
Copy link
Copy Markdown
Owner Author

@mtelka would this work for you?

Comment thread tox.ini
all
testing
commands =
pytest --doctest-modules src
Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the redundancy.

@abravalheri abravalheri marked this pull request as ready for review September 17, 2024 17:12
@mtelka
Copy link
Copy Markdown

mtelka commented Sep 17, 2024

I'm happy to report that with git main + this change all tests pass here. Thank you!

@abravalheri abravalheri merged commit 15c9724 into main Sep 23, 2024
@abravalheri abravalheri deleted the issue-200 branch September 23, 2024 11:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Many tests fails with generator raised StopIteration

3 participants