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

add directive to enable something like "skip if" #16

Closed
eteq opened this issue Jan 15, 2018 · 4 comments
Closed

add directive to enable something like "skip if" #16

eteq opened this issue Jan 15, 2018 · 4 comments

Comments

@eteq
Copy link
Contributor

eteq commented Jan 15, 2018

A constant thorn in our side when writing doc tests for astropy.coordinates is the need to # doctest: +SKIP anything that uses scipy, since it's an optional dependency. It would be better if we could do something like # doctest: +SKIP_IF_HAS_SCIPY. doctestplus might be a good place for this, but the challenge is: how to define this sensibly? ideally one would have a skipif that's fairly generic, not hard-coded to Scipy...

cc @drdavella

@bsipocz
Copy link
Member

bsipocz commented Jan 18, 2018

@eteq - wouldn't the .. doctest-requires: scipy directive be a good alternative for now? Afaik you still have to state it before each snippet, but it's still way better than adding SKIP to every line.

@drdavella drdavella reopened this Mar 2, 2018
@oscarbenjamin
Copy link
Contributor

Sympy's test runner has solved this using a decorator to mark a particular function/class for skipping.

You can see the decorator here: https://github.com/sympy/sympy/blob/sympy-1.3/sympy/utilities/decorator.py#L130

Also an example of use is here: https://github.com/sympy/sympy/blob/sympy-1.3/sympy/printing/preview.py#L23

I'm not sure if doctestplus should grow something as complicated as that but certainly a decorator for skipping doctests would be useful. As long as doctestplus has the machinery to skip doctests from a marked function then downstream projects can extend that with as much conditional functionality as they like.

So I would suggest just to keep it simple and add a decorator called doctest_skip.

@RonnyPfannschmidt
Copy link

sphinx-doc/sphinx#5307 is also a potential implementation and closer to the restructuretext bits

@bsipocz
Copy link
Member

bsipocz commented Oct 2, 2022

as per my comment above I think we have this functionality already. At least for that was my understanding reading the narrative of the OP. Reading the example is something else though, so if you indeed mean adding functionality that SKIPs when something is installed, then please reopen and provide more details about the use case you have in mind.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants