microsoft / knossos-ksc

Compiler with automatic differentiation
Other
45 stars 10 forks source link

Doctests of path.py, run from test_pytest.sh #923

Closed acl33 closed 3 years ago

acl33 commented 3 years ago

This adds some usage examples of Path / ExprWithPath, whose correctness are tested by doctest, run within pytest using the --doctest-modules flag.

doctest is quite limited; majorly in that everything is about the text printed out by an interactive python interpreter session. So the examples have to fit that.

Besides pytest --doctest-modules, these can also be run directly from the command-line via python -m doctest [-v] -o ELLIPSIS src/python/ksc/path.py. The -v is useful for debugging; the ELLIPSIS because this seems to be turned on by default when running under pytest. Do we want to add python3 -mdoctest -o ELLIPSIS src/python/ksc/*.py to test_pytest.sh as an additional step to document this possibility?

(I think we want to keep the pytest --doctest-modules as python3 -mdoctest produces zero output upon success, so you can't even see anything's been run; with -v there are reams of output including every line of test, every expected+actual output, and every file scanned.)