PyCon UK 2015

Getting started with testing scientific programs

Martin Jones

When writing programs for scientific research, we tend to be focussed on getting results, so testing is generally not a priority. Often, this means that our data-processing pipelines end up incorporating programs that don't have test suites. Examples of high-profile retractions due to software errors (e.g. illustrate the dangers of this approach.

This session will be a gentle introduction to testing, aimed at people writing scientific software who would like to start taking advantage of automated testing. We'll start with Python’s built-in tools and moving on to using the Nose testing framework. We’ll look at the problems that testing can solve, and see some best-practises for writing tests.


The goal of this training session is for attendees to come away with (1) an understanding of some basic testing concepts, (2) some hands-on experience of running tests and interpreting the output, and (3) an idea of how to start applying these tools to their own projects.

Who should attend this session

Attendees should have a basic knowledge of Python and should be familiar with the idea of functions, conditions and exceptions. They should also have the Nose package installed (pip install nose should work in most cases).

What to do before this session

If you plan to attend this workshop, you can make things run smoothly by making sure that you have the nose module installed. Follow the instructions on the nose website. You'll also need internet access in order to download the example files, so make sure you can connect to the conference wifi.