Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for running doctest as part of pytest #161

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open

Conversation

nh13
Copy link
Member

@nh13 nh13 commented Jul 16, 2024

I have futzed with the trim_doctest_flags within the mkdocstrings options in pyproject.yml but still don't get the # doctest +FLAG removed. Help is welcome.

@nh13 nh13 requested a review from tfenne as a code owner July 16, 2024 21:17
Copy link

codecov bot commented Jul 16, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.48%. Comparing base (aa6c74b) to head (bd2a2ae).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #161      +/-   ##
==========================================
+ Coverage   89.02%   89.48%   +0.45%     
==========================================
  Files          17       17              
  Lines        2005     2006       +1     
  Branches      437      437              
==========================================
+ Hits         1785     1795      +10     
+ Misses        144      138       -6     
+ Partials       76       73       -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@nh13 nh13 temporarily deployed to github-actions-ci July 18, 2024 15:34 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 18, 2024 15:34 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 18, 2024 15:34 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 18, 2024 15:34 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 18, 2024 15:34 — with GitHub Actions Inactive
fgpyo/fasta/builder.py Outdated Show resolved Hide resolved
Comment on lines +39 to +40
>>> contig_one.add("NNN", 1) # doctest: +ELLIPSIS
<fgpyo.fasta.builder.ContigBuilder object at ...>
Copy link
Contributor

Choose a reason for hiding this comment

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

naive q: can the doctest: +ELLIPSIS pragma be moved to the following line, where the ellipsis actually exists? Or is it required to be on the line with the code being run, not the output?

Copy link
Member Author

Choose a reason for hiding this comment

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

It has to be on the line :/

@@ -9,10 +9,10 @@
>>> import pysam
>>> from fgpyo.fasta.sequence_dictionary import SequenceDictionary
>>> sd: SequenceDictionary
>>> with pysam.AlignmentFile("./fgpyo/sam/tests/data/valid.sam") as fh:
... sd = SequenceDictionary.from_sam(header=fh.header)
>>> with pysam.AlignmentFile("./tests/fgpyo/sam/data/valid.sam") as fh:
Copy link
Contributor

Choose a reason for hiding this comment

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

For clarity I might SKIP this and replace with a dummy path, as in the test for FastxZipped below

Copy link
Member Author

Choose a reason for hiding this comment

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

I like this since it actually runs!

Assert that a path exists and is readable

```python
>>> tmp_dir = Path(getfixture("tmp_path"))
Copy link
Contributor

Choose a reason for hiding this comment

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

where is getfixture defined?

Copy link
Member Author

Choose a reason for hiding this comment

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

@nh13 nh13 temporarily deployed to github-actions-ci July 18, 2024 18:08 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 18, 2024 18:08 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 18, 2024 18:08 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 18, 2024 18:08 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 18, 2024 18:08 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 18, 2024 18:08 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 18, 2024 18:08 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 18, 2024 18:08 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 18, 2024 18:08 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 18, 2024 18:08 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 18, 2024 18:10 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 18, 2024 18:10 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 18, 2024 18:10 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 18, 2024 18:10 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 18, 2024 18:10 — with GitHub Actions Inactive
@nh13 nh13 requested a review from msto July 18, 2024 18:50
@nh13 nh13 temporarily deployed to github-actions-ci July 19, 2024 04:23 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 19, 2024 04:23 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 19, 2024 04:23 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 19, 2024 04:23 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 19, 2024 04:23 — with GitHub Actions Inactive
@pawamoy
Copy link

pawamoy commented Jul 20, 2024

I have futzed with the trim_doctest_flags within the mkdocstrings options in pyproject.yml but still don't get the # doctest +FLAG removed. Help is welcome.

It's probably because Griffe's parsers will only detect and remove doctest flags in raw pycon code block (not wrapped in fences), and only in examples section:

"""Summary.

Examples:
    Some example.

    >>> print("hey")
    hey
"""

I have written a Python-Markdown extension that enables such raw pycon code blocks anywhere in Markdown (stripping doctest flags again), but it's only available to sponsors for now: https://pawamoy.github.io/markdown-pycon/.

@nh13 nh13 temporarily deployed to github-actions-ci July 24, 2024 20:45 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 24, 2024 20:45 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 24, 2024 20:45 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 24, 2024 20:45 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 24, 2024 20:45 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 25, 2024 07:27 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 25, 2024 07:27 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 25, 2024 07:27 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 25, 2024 07:27 — with GitHub Actions Inactive
@nh13 nh13 temporarily deployed to github-actions-ci July 25, 2024 07:27 — with GitHub Actions Inactive
@nh13 nh13 removed the request for review from msto August 1, 2024 17:51
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.

3 participants