Add "doctest" session ...

... to run `xdoctest` against the `velofy` package.

Also, install `xdoctest` with only its "colors" extra
as the notebooks do not contain doctests.
This commit is contained in:
Alexander Hess 2026-11-27 10:45:35 +01:00
commit 32f6540ec3
Signed by: alexander
GPG key ID: B46EDB4DFC26805D

View file

@ -133,6 +133,7 @@ nox.options.sessions = (
'format',
'lint',
'test',
'doctest',
)
# Make `uv` use its own Python no matter what
@ -252,6 +253,31 @@ def test_code(session: Session) -> None:
session.run('pytest', *(session.posargs or pytest_default_args))
@nox.session(name='doctest', python=MAIN_PYTHON)
def test_docstrings(session: Session) -> None:
"""Test the code snippets in the docstrings with `xdoctest`.
By default, all docstrings in the package are checked.
Extra arguments are forwarded to `xdoctest`.
"""
start(session)
install_pinned(session, '.', 'xdoctest[colors]')
# As `pytest-env` does for `pytest`,
# keep `velofy` from connecting to the production database
session.env['TESTING'] = 'true'
session.run(
'python',
'-m',
'xdoctest',
PACKAGE_IMPORT_NAME,
*(session.posargs or ('all',)),
)
@nox.session(name='deps-audit', python=MAIN_PYTHON, reuse_venv=False)
def audit_pinned_dependencies(session: Session) -> None:
"""Check dependencies for vulnerabilities with `pip-audit`.