Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make compatible with pytest-asyncio #278

Merged
merged 2 commits into from
Jan 21, 2025

Conversation

geigerzaehler
Copy link
Contributor

pytest-asyncio reads 1 collector.obj during test collection which raises an ImportError for DocTestTextfilePlus. We fix this by aligning that class with pytest’s DoctestTextfile 2 and setting obj to None.

Fixes #256

`pytest-asyncio` reads [1] `collector.obj` during test collection which
raises an `ImportError` for `DocTestTextfilePlus`. We fix this by
aligning that class with pytest’s `DoctestTextfile` [2] and setting
`obj` to `None`.

Fixes scientific-python#256

[1]: https://github.com/pytest-dev/pytest-asyncio/blob/eb63d5ad0ca21041726ada3d5c00211d36418a9b/pytest_asyncio/plugin.py#L640
[2]: https://github.com/pytest-dev/pytest/blob/fc56ae365fcdea800f91683186136a8191e22399/src/_pytest/doctest.py#L421
@pllim pllim requested a review from bsipocz January 21, 2025 15:43
@pllim pllim added this to the v1.4.0 milestone Jan 21, 2025
@pllim
Copy link
Contributor

pllim commented Jan 21, 2025

Needs a change log: https://github.com/scientific-python/pytest-doctestplus/blob/main/CHANGES.rst

Thanks! LGTM but I'll let Brigitta have a look too.

Copy link
Member

@bsipocz bsipocz left a comment

Choose a reason for hiding this comment

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

All looks good and works as expected. I love when a long-standing issue is boiled down into a one-liner fix. Thank you @geigerzaehler!

@bsipocz bsipocz merged commit 81fe4fd into scientific-python:main Jan 21, 2025
@bsipocz
Copy link
Member

bsipocz commented Jan 21, 2025

I'll tag a release this week, first see if any more fixes can be added to it.

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.

ModuleNotFoundError with pytest-asyncio
3 participants