-
Notifications
You must be signed in to change notification settings - Fork 37
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 skipping of doctests more visible? #246
Comments
Playing around with this, I think one approach would be to insert new lines into doctests during collection that cause pytest to skip. E.g. --- pytest_doctestplus/plugin.py
+++ pytest_doctestplus/plugin.py
@@ -874,8 +874,14 @@
else:
continue # The pattern does not apply
- if not self.check_required_modules(mods):
- return False
+ for mod in mods:
+ example = doctest.Example(
+ source=f"import pytest; pytest.importorskip({mod!r})",
+ want="",
+ exc_msg=None,
+ )
+ test.examples.insert(0, example)
+
return True
tests = list(filter(test_filter, tests)) Not sure how "hacky" you consider this approach but it seems to address my feature request perfectly. |
I wonder if @nicoddemus & co could advise since we plug into doctest within pytest itself. Any performance impact? |
I agree that counting them into the skipped total would be nice (though big narrative docs file usually count as one, so partial skipping rst files may not be able to work this way) |
Right, the suggested patch and our usage in scikit-image are mainly concerned with docstrings right now. |
We've started using doctestplus in scikit-image and I'm happy with it so far. However, my main gripe with it is that (conditional) skipping doctest isn't very visible. E.g. when I use
__doctest_requires__
to mark functions then these are just silently not collected and ignored. Instead I would like to figure out if we can still collect these but mark them to be skipped the same way as if I addedpytest.importorskip("pywt")
to the doctest itself...I could try looking into this but first I'd like to know if there are any concerns with this approach. And also were I should start..
The text was updated successfully, but these errors were encountered: