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

doctest_public_modules.py -t filename fails if a docstring example ends without a blank line #105

Open
ev-br opened this issue Feb 16, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@ev-br
Copy link
Member

ev-br commented Feb 16, 2024

$ python tools/doctest_public_modules.py -t scipy/linalg/_basic.py -v

...

File "scipy/linalg/_basic.py", line 1026, in _basic.py
Failed example:
    linalg.det(c[0, 0])  # Confirm the (0, 0) slice, [[1, 2], [3, 4]]
Expected:
    -2.0
    """
    # The goal is to end up with a writable contiguous array to pass to Cython
Got:
    -2.0

The technical problem is that the docstring ends without a blank line --- https://github.com/scipy/scipy/blob/main/scipy/linalg/_basic.py#L1028 --- so the parser fails to detect the end of example and consumes the rest of the docstring + code all the way until the next blank line.

This does not happen for -s submodule: the -t invocation goes through the testfile not testmod. Another consequence of this is that with testfile we end up with a single Doctest with all examples from all docstrings. With testmod we'd get a Doctest per docstring, but not with testfile.

Stepping back, using testfile seems to be a hack really.

@ev-br ev-br added the bug Something isn't working label Feb 16, 2024
@ev-br ev-br changed the title dev.py -t filename fails if a docstring example ends without a blank line doctest_public_modules.py -t filename fails if a docstring example ends without a blank line Feb 21, 2024
@ev-br
Copy link
Member Author

ev-br commented Feb 21, 2024

  • $ python dev.py -t path/to/file does not work either, just does not do anything
  • $ pytest --doctest-modules path/to/file fails at (ISTM) package imports.

So there are two issues, both need to be fixed from the ground up:

  • testfile uses a too-naive parser, even for rst tutorials. This is Parse python code blocks in TeX, md, rst etc #56.
  • selecting a single file to doctest fails all around, needs to be fixed from the ground up. Does it work with vanilla doctests?

Also cross-ref #114 : should -t go through strategy="path/to/file"?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant