-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Improve test coverage by moving self-tests #820
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
Comments
Here's an indication of some obvious targets to tackle next: $ python count_main.py Bio BioSQL
Walking Bio
26 726 Bio/bgzf.py
48 258 Bio/MaxEntropy.py
32 194 Bio/NaiveBayes.py
44 622 Bio/Align/AlignInfo.py
246 574 Bio/AlignIO/FastaIO.py
65 179 Bio/AlignIO/NexusIO.py
25 535 Bio/Blast/NCBIXML.py
358 1730 Bio/GenBank/Scanner.py
11 180 Bio/Graphics/GenomeDiagram/_Colors.py
16 184 Bio/Graphics/GenomeDiagram/_FeatureSet.py
8 172 Bio/Graphics/GenomeDiagram/_GraphSet.py
26 302 Bio/Graphics/GenomeDiagram/_Track.py
29 217 Bio/KDTree/KDTree.py
29 161 Bio/KEGG/KGML/KGML_parser.py
57 1760 Bio/Nexus/Nexus.py
6 61 Bio/PDB/Dice.py
15 344 Bio/PDB/DSSP.py
10 276 Bio/PDB/FragmentMapper.py
26 301 Bio/PDB/HSExposure.py
25 91 Bio/PDB/MMCIF2Dict.py
13 196 Bio/PDB/MMCIFParser.py
9 163 Bio/PDB/NACCESS.py
12 118 Bio/PDB/NeighborSearch.py
12 245 Bio/PDB/parse_pdb_header.py
16 202 Bio/PDB/PDBIO.py
44 303 Bio/PDB/PDBList.py
19 280 Bio/PDB/PDBParser.py
24 408 Bio/PDB/Polypeptide.py
8 87 Bio/PDB/PSEA.py
9 138 Bio/PDB/ResidueDepth.py
27 117 Bio/PDB/StructureAlignment.py
17 66 Bio/PDB/Superimposer.py
55 319 Bio/PDB/Vector.py
42 160 Bio/PDB/QCPSuperimposer/__init__.py
15 329 Bio/SeqIO/SeqXmlIO.py
186 1366 Bio/SeqIO/SffIO.py
18 146 Bio/SeqIO/SwissIO.py
13 113 Bio/SeqUtils/CheckSum.py
30 136 Bio/SVDSuperimposer/__init__.py
16 536 Bio/SwissProt/__init__.py
11 351 Bio/UniProt/GOA.py
Walking BioSQL
Done This was a quick script to count the number of (non-blank) lines after the import sys
import os
def count(filename):
total = 0
in_main = False
main = 0
with open(filename) as in_handle:
for line in in_handle:
if not line.strip():
continue
total += 1
if line.startswith("if ") and "__main__" in line:
in_main = True
if in_main:
main += 1
if main > 5:
print("%i\t%i\t%s" % (main, total, filename))
return main, total
for path in sys.argv[1:]:
print("Walking %s" % path)
for (dirpath, dirnames, filenames) in os.walk(path):
for f in filenames:
if f.endswith(".py"):
count(os.path.join(dirpath, f))
print("Done") |
This was covered by test_SwissProt.py anyway, see GitHub issue #820.
Parsing this file was covered in test_SeqXmlIO.py anyway. See GitHub issue #820.
Already covered by test_SeqUtils.py - see GitHub issue #820
@peterjc you might want to label this easy. |
Good point Vincent - it will vary case by case, but a lot of these should be fairly easy jobs - and the task is well defined. |
For review: Considering coverage of SffIO docstests (56%) VS test_SffIO (57%) VS selftest(73%). |
Those figures are certainly strong motivation to move the SFF self-tests into our unit-test framework. Looking back it was a mistake to write the tests that way in the first place, but I've grown to appreciated automated testing more and more over the years. |
@peterjc I would like to work on the issue |
Hi @souravsingh - how about working on |
#948 from @vincentdavis did this for |
Updated list.
|
Heya, I'm giving Bio/AlignIO/FastaIO.py a go 😄 |
Hi, I'm having a look at Bio/Blast/NCBIXML.py. Ideally the class should be tested with every kind of blast XML output found in Test/Blast? Ex: blastn, blastp, etc? |
@Gasta88 that's an interesting one, right now https://github.com/biopython/biopython/blob/master/Bio/Blast/NCBIXML.py#L646 (link points at current latest code) when run directly takes a filename via the command line, and tries parsing it. I think we/you could just delete that In terms of test coverage, other than this If you wanted to look at that, adding tests to |
See previous commit from pull request 1063, working towards issue #820 on improving test coverage.
in reference to issue biopython#820, moved self_test into doctest format
Hi @peterjc , I see that Is it ok if I edit this script to use |
@Gasta88 from a quick check by eye, the current If you also wanted to convert |
New numbers:
These are executable code so a false positive:
These are all self tests to review:
|
I'll have a look at Bio/PDB/Dice.py |
I'll have a look at Bio/PDB/NeighborSearch. |
I'll work on Bio/PDB/DSSP.py, also relates to #1288. |
@svalqui you'll need to install the command line tool DSSP to try this. It may turn out that the self-test functionality is already covered in https://github.com/biopython/biopython/blob/master/Tests/test_DSSP_tool.py (in which case we can remove the |
@peterjc Thank you for that I had missed test_DSSP_tool, which takes care of dssp; I have removed if name is main. I will have a look at Bio/Graphics/GenomeDiagram/_FeatureSet.py. |
Already covered with test_DSSP_tool.py - see issue #820.
Self test on:
|
I'll have a look at Bio/GenBank/Scanner.py |
Some bits of these self tests no longer worked, and it looks like everything else is covered in Tests/test_GenomeDiagram.py Partly addresses issue #820.
Testing the same method in Tests/test_GenBank_unitest.py instead, using existing example files. Addresses part of GitHub issue #820.
These are executable code so a false positive:
These are all self tests to review:
|
Running that script again now against the current default branch: ❯ python count_main.py Bio BioSQL
Walking Bio
30 825 Bio/bgzf.py
103 687 Bio/PDB/PDBList.py
10 179 Bio/PDB/NACCESS.py
Walking BioSQL
Done Those three are not self-tests, but simple command line functionality. Closing this issue as completed. |
Uh oh!
There was an error while loading. Please reload this page.
Many of the Python files in Biopython still have self-tests at the end which are executed if the file is run directly via the idiom:
This is bad for several reasons - these tests are not being run routinely via our buildbot [Update: We stopped using buildbot, but now have AppVeyor instead] or TravisCI (and therefore if the test breaks, we don't know about it), they are not counted on the coverage report https://codecov.io/github/biopython/biopython/ (and in fact actively reduce the coverage score [Update: We configured codecov to ignore the self tests]), and moreover with Python 3 making subtle changes to imports, some of these self tests have accidentally become Python 2 only.
This is a tracking issue to encourage more commits like these which move these self-tests under
Tests/test_XXX.py
using the unittest framework instead:Or, in some cases using a doctest instead makes sense:
In those cases, we're left with a stub like this which is useful when working directly on a file's doctests:
The text was updated successfully, but these errors were encountered: