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

Switch to sphinx doctest to avoid implicit import problem #208

Open
agoscinski opened this issue Aug 14, 2023 · 1 comment
Open

Switch to sphinx doctest to avoid implicit import problem #208

agoscinski opened this issue Aug 14, 2023 · 1 comment

Comments

@agoscinski
Copy link
Collaborator

Hello when I replaced the code snippets in PR #201 I used sphinx doctest to have them in the docs/src, but in PR #202 we move it to an __init__ file, so we don't need sphinx doctest anymore. But I noticed that with sphinx doctest the implicit problem does not exist:

import numpy as np

#. ..
class SomeClass:
    """
    >>> a = np.array([5])
    """
    pass

The doctest in pytest does not fail because it gets the import at the beginning of the file, but when one sees the example in the doc or help page, one does not know this. So one has to remember to add imports into the doctest when using pytest. With sphinx doctest this test would fail because of the missing import. Therefore this issue is to discuss a switch to sphinx doctest. There might be some downsides using sphinx doctest that I have not realized yet.

Also @PicoCentauri suggests move the sphinx doctest then to the test environment in tox which makes sense. After the PR #202 we do not have any doctest in the docs, so I think we can do it.

@PicoCentauri
Copy link
Collaborator

This is really weird, that pytest runs these lines without any issues. I just checked it with other projects and there we use the same config and have to add the line

>>> import numpy as np

in order to run the tests.

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

No branches or pull requests

2 participants