Skip to content

Compare the coverage

Evgeni Burovski edited this page Feb 21, 2024 · 6 revisions

We have tree ways of checking running the doctests on SciPy:

  1. The old way: refguide-check
  2. The doctest way: via the doctesting layer
  3. The pytest-plugin way: via the pytest plugin layer.

We want to make sure that the "new" ways have at least the same coverage as the refguide-check way. Here's how.


The pytest plugin way

$ python dev.py shell
$ cd path/to-scipy/folder
$ pytest build-install/lib/python3.10/site-packages/scipy/ --doctest-modules --ignore=build-install/lib/python3.10/site-packages/scipy/interpolate/_interpnd_info.py --ignore=build-install/lib/python3.10/site-packages/scipy/_lib --collect-only > plugin.log

Then run the plugin.log through a small utility to extract the names of functions and classes:

"""
convert the result of 
$ pytest ... --doctest-modules --collect-only
to simplify comparing to the doctest_.log from doctest-based runs
"""

if __name__ == "__main__":
    import sys
    if len(sys.argv) != 2:
        print("Usage: modify_log.py LOGFILE")

    fname = sys.argv[1]
    with open(fname, 'r') as inf:
        in_lines = inf.readlines()

    out_lines = []
    for line in in_lines:
        line_ = line.strip()
         
        if line_.startswith("<DoctestItem"):
            out_lines.append(line_[13:-1])

    print("\n".join(sorted(out_lines)))

The refguide-check way

https://github.com/scipy/scipy/pull/16391 patches the refguide-check utility so that running

$ python dev.py refguide-check

drops a file refguide_check.log in the SciPy root folder.

Clone this wiki locally