Testing Biopython

Biopython is distributed for Python 2.6 through 3.4 from a single codebase, Biopython is also written with the intention to maintain support for alternative Python distributions such as Pypy and Jython. Constant and careful testing is an important step during development to maintain broad compatibility. Several options exist for this task. The easiest but least flexible method is to use the system Python interpreters. Ubuntu 14.04 includes Python 2.7 and 3.4. Ubuntu also has pypy-2.2 in the default repositories. These interpreters can be used directly with the unit-tests. A disadvantage to using the system interpreters directly is the eventual contamination caused by adding many different versions of various dependencies. In order to avoid this downside, more advanced approaches involving virtualization technology, such as Docker, are an option.

In my case, I used a middle road involving much less work than full scale virtualization but conferring some of the benefits. Virtualenv is a Python extension that allows the creation of an isolated instance/environment of Python. Virtualenv still requires the selected version of Python to be fully installed on a system but allows you to isolate a branch from changes normally made at a system level. In order to cover a broad range of Python compilers I used Felix Krull's Deadsnakes PPA which contains older versions of Python not included in the default Ubuntu repositories.

Shortly, I can support local versions of Python in dedicated folders by running the following commands in a dedicated folder in my home directory:

virtualenv -p python2 py27Virtualenv
virtualenv -p python3 py34Virtualenv
virtualenv -p pypy pypyVirtualenv

Using the command 'source /path/to/virtualenv/bin/activate' alters my console to use the virtualenv Python interpreter as the default Python interpreter rather than the system interpreter. Changes to this interpreter can easily be rolled back by simply deleting the folder and making a new one.

In addition to running tests locally, Biopython also can take advantage of Travis-CI to monitor stability of a branch. Travis-CI is a continuous integration service that seamlessly integrates with github. Once activated on an account, Travis-CI will run a series of tests on a broad range of Python versions via instructions included in a .travis.yml file included with Biopython. Travis-CI testing compliments in situ testing and works as a backup / final level of error checking.


Popular posts from this blog

Indexing XML files in Python

Fasta performance comparison

Building Biopython on Windows