Skip to content

Conversation

@mtauraso
Copy link
Contributor

@mtauraso mtauraso commented Apr 14, 2025

Change Description

Addressing #379.

Turning on doctest by default in ppt. This base configuration will:

  1. Enable doctests for tests defined in inline doc comments in source
  2. Enable doctests for tests defined in documentation .rst files that use the >>> syntax

This is not particularly fancy, but will give a "batteries included" setup to anyone who wants to use doctests.

I have added a little bit of documentation, but it feels like its too far at the leaf of a documentation tree for anyone to find.
Perhaps this is okay?

Checklist

  • This PR is meant for the lincc-frameworks/python-project-template repo and not a downstream one instead.
  • This change is linked to an open issue
  • This change includes integration testing, or is small enough to be covered by existing tests

@mtauraso mtauraso requested a review from hombit April 14, 2025 21:17
@mtauraso mtauraso linked an issue Apr 14, 2025 that may be closed by this pull request
@mtauraso mtauraso requested a review from drewoldag April 14, 2025 21:18
Copy link
Collaborator

@drewoldag drewoldag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PPT can create example modules - it might make sense to include a doctest in one or both of the example functions.

Copy link
Contributor

@hombit hombit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you! There is one comment only, maybe you meant to put a different link for .rst-doctest examples.

`doctest <https://doc.pytest.org/en/latest/how-to/doctest.html>`_ component.
Documentation comments in all source files, as well as ``.rst`` files in the ``./docs``
directory can contain doctests in the format outlined
`here <https://doc.pytest.org/en/latest/how-to/doctest.html>`_.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should it be some other link?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure there's a better one. This change doesn't include anything .rst specific, so you just have to use the normal syntax in your .rst files.

AFAICT that one page is the only obviously authoritative place on the internet that explains the syntax. If we somehow do something special and more .rst friendly we could amend this.

Copy link
Contributor

@hombit hombit Apr 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doctest is a part of PEP287, and it is support by the standard library's doctest module. So pytest docs is not the only authoritative place...

@mtauraso
Copy link
Contributor Author

The PPT can create example modules - it might make sense to include a doctest in one or both of the example functions.

Just added this.

Copy link
Collaborator

@drewoldag drewoldag left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@mtauraso mtauraso merged commit cc3fcaf into main Apr 14, 2025
5 checks passed
@mtauraso mtauraso deleted the doctest branch April 14, 2025 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Option to run doctests

4 participants