Repository navigation
Use pytest-doctestplus instead of classic pytest-doctest - #7289
Merged
Merged
Conversation
This has the advantage of being able to hide custom test setup from the rendered HTML docstrings and many more perks we might use in the future. doctestplus has its own mechanism of skipping doctests if dependencies are not required. However, it seems that using `__doctest_skip__` will not show that tests were skipped, so instead I'm using an approach based on `.. testsetup` and `pytest.importorskip`.
lagru
commented
Jan 11, 2024
Comment on lines
+82
to
+84
| .. testsetup:: | ||
| >>> import pytest; _ = pytest.importorskip('sklearn') | ||
|
|
Member
Author
There was a problem hiding this comment.
doctestplus has its own mechanism of skipping doctests if dependencies are missing. However, it seems that using __doctest_skip__ will not show that tests were skipped and I couldn't get .. doctest-requires:: to work. So instead I'm using an approach based on .. testsetup and pytest.importorskip.
18 tasks done
as well. It's needed to parse the .. testsetup fixture.
soupault
reviewed
Jan 15, 2024
| -------- | ||
| >>> import pytest | ||
| >>> _ = pytest.importorskip('sklearn') | ||
| .. testsetup:: |
Member
There was a problem hiding this comment.
I like the explicitness of this!
soupault
approved these changes
Jan 15, 2024
soupault
left a comment
Member
There was a problem hiding this comment.
I think it is a good addition considering the size and the complexity of our tests codebase.
mkcor
approved these changes
Jan 16, 2024
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This has the advantage of being able to hide custom test setup from the rendered HTML docstrings and many more perks we might use in the future. E.g. in the past I've wished for access to
# doctest: +FLOAT_CMP,# doctest: +IGNORE_WARNINGSor.. testsetup::.See also https://github.com/scientific-python/pytest-doctestplus.
Checklist
./doc/examplesfor new featuresRelease note
Summarize the introduced changes in the code block below in one or a few sentences. The
summary will be included in the next release notes automatically: