Contribute Media
A thank you to everyone who makes this possible: Read More

Version Control and Unit Testing for Scientific Software, SciPy2013 Tutorial, Part 3 of 3


Presenters: Matt Davis, Katy Huff


Writing software can be a frustrating process but developers have come up with ways to make it less stressful and error prone. Version control saves the history of your project and makes it easier for multiple people to participate in development. Unit testing and testing frameworks help ensure the correctness of your code and help you find errors by quickly executing and testing your entire code base. These tools can save you time and stress and are valuable to anyone writing software of any description.

This collaborative, hands-on tutorial will cover version control with Git plus writing and running unit tests in Python (and IPython!) using the nose testing framework. Attendees should be comfortable with the basics of Python and the command line but no experience with scientific Python is necessary.


The tutorial will be split into two two-hour lessons. The first lesson will cover git/GitHub and the second lesson will cover unit testing. Throughout the entirety of the tutorial students will be working in pairs. Our teaching style is to have frequent, short exercises for students. Ideally instructors aren't talking for more than a few minutes before they stop and students do something on their own machines. Instructors then give an explanation and example, then move on to the next item.

Lesson 1: git/GitHub

Students will work in pairs and in each pair one student will make a GitHub repo, then give the other student commit access on that repo. Students will take turns making modifications to learn various bits of git functionality.

Lesson 2: Unit Testing

Continuing to work in pairs, students will use test driven development to construct a small scientific program in the IPython Notebook and then take their work to .py files to see how nose works from the command line.

Required Packages

In addition to standard Python this tutorial will require the nose testing framework, the IPython Notebook, and the command line interface to Git. Installing Git varies by platform. Windows users should install Git Bash (aka msysgit), Mac users should install the Mac OS X Command Line Tools, and Linux users should use the packaging system for their particular Linux distribution. The Anaconda CE Python installer includes nose and the IPython Notebook.


Material will be adapted from existing Software Carpentry lessons, especially:

Other links: - The software carpentry organization with links to many lessons and past boot camps. - Standard Software Carpentry boot camp curriculum. - Early Software Carpentry curriculum from a two week boot camp at the International Center for Theoretical Physics. - Lesson notes for a three hour lightning lesson at the American Nuclear Society Conference 2011. - A blog post about the first week of the two week ICTP boot camp. - A blog post about a two day boot camp at the University of Chicago. - A blog post about what the hacker within did before it was absorbed into Software Carpentry (it's no longer really its own entity).

Improve this page