scipy / scipy_doctest

Floating-point aware doctesting
BSD 3-Clause "New" or "Revised" License
5 stars 4 forks source link

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

Open ev-br opened 7 months ago

ev-br commented 7 months ago
$ 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 commented 6 months ago

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

Also cross-ref https://github.com/ev-br/scpdt/issues/114 : should -t go through strategy="path/to/file"?