Skip to content

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

Open
@ev-br

Description

@ev-br
$ 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions