Skip to content

Improve test coverage by moving self-tests #820

Description

@peterjc

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:

if __name__ == "__main__":
    print("Running a quick self-test")
    ...

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:

if __name__ == "__main__":
    from Bio._utils import run_doctest
    run_doctest(verbose=0)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions