-
Notifications
You must be signed in to change notification settings - Fork 3
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
base: main
Are you sure you want to change the base?
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
>>> contig_one.add("NNN", 1) # doctest: +ELLIPSIS | ||
<fgpyo.fasta.builder.ContigBuilder object at ...> |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is getfixture
defined?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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/. |
I have futzed with the
trim_doctest_flags
within themkdocstrings
options inpyproject.yml
but still don't get the# doctest +FLAG
removed. Help is welcome.