pyani
pyani copied to clipboard
Add `try/except` around extraction to accommodate failing uncompression in `pyani download`
Fixes problem where failure to extract the contents of individual zip files from pyani download triggers a SystemExit.
Closes #383.
Please include a summary of the change and which issue is fixed. Please also include the motivation and context, and note the tests that apply to these changes.
Type of change
- [x] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality not to work as expected)
- [ ] This change requires a documentation update
- [ ] This is a documentation update
Action Checklist
- [x] Work on a single issue/concept (if there are multiple separate issues to address, please use a separate pull request for each)
- [ ] Fork the
pyanirepository under your own account (please allow write access for repository maintainers) - [x] Set up an appropriate development environment (please see
CONTRIBUTING.md) - [x] Create a new branch with a short, descriptive name
- [x] Work on this branch
- [x] style guidelines have been followed
- [x] new code is commented, especially in hard-to-understand areas
- [ ] corresponding changes to documentation have been made
- [ ] tests for the change have been added that demonstrate the fix or feature works
- [x] Test locally with
pytest -vnon-passing code will not be merged - [x] Rebase against
origin/master - [x] Check changes with
flake8andblackbefore submission - [x] Commit branch
- [x] Submit pull request, describing the content and intent of the pull request
- [ ] Request a code review
- [ ] Continue the discussion at
Pull requestssection in thepyanirepository
Codecov Report
Merging #385 (48119e4) into master (62949c4) will decrease coverage by
0.07%. The diff coverage is58.33%.
@@ Coverage Diff @@
## master #385 +/- ##
==========================================
- Coverage 75.82% 75.74% -0.08%
==========================================
Files 55 55
Lines 3747 3756 +9
==========================================
+ Hits 2841 2845 +4
- Misses 906 911 +5
Even with the custom exception class, the fact that I am handling the error means pytest does not recognise it as thrown if the test is called from the top of subcmd_download. Using download.exract_genomes() as the entry point might solve it, but will require the creation of several fixtures to pass as its parameters—and those fixtures will be basically identical to the return values of the mocked functions in mock_single_genome_dl.
I believe passing fixtures into mock functions (that use the monkeypatch fixture) is not really done, or I would abstract out the objects to avoid redundancy.
Currently, I have opted to write a unit test for download.extract_contigs(), the most proximal source of the raised Exception. This is rather straightfoward, as the error is not handled there, and the only inputs are two Paths. However, it means that the actual try/except blocks are flagged by codecov.
Should I pursue tests for those blocks?
@widdowquinn Do you find the current state of testing for these changes sufficient, or would you want to see something else?