-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Use pytest-doctestplus instead of classic pytest-doctest #7289
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`.
.. testsetup:: | ||
>>> import pytest; _ = pytest.importorskip('sklearn') | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
.
as well. It's needed to parse the .. testsetup fixture.
@@ -79,8 +79,9 @@ def learn_gmm(descriptors, *, n_modes=32, gm_args=None): | |||
|
|||
Examples | |||
-------- | |||
>>> import pytest | |||
>>> _ = pytest.importorskip('sklearn') | |||
.. testsetup:: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the explicitness of this!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is a good addition considering the size and the complexity of our tests codebase.
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_WARNINGS
or.. testsetup::
.See also https://github.com/scientific-python/pytest-doctestplus.
Checklist
./doc/examples
for 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: