Automated Python education via unit testing and Travis-CI

Sometimes education can be a daunting process. It is quite obvious from the student side, we all have gone through exercises, corrections, learning what we did wrong on some of them, fixing and learning from those errors, rinse and repeat. That’s how it generally works.

On the teacher’s side, correcting assignments is easy and unbiased unless the number of students is considerably large. At
one of the sessions of our now official KTH course “DD3436 Scientific Programming in Python for Computational Biology” I was given the task to hold a session on software testing and continuous integration in Python… for around 50 students.

So I wanted to find a simple way to teach Python without going through the old beaten track of the boring fibonnacci function and endless lists of exercises. Something like little incremental goals that kept students hooked until they finished the training for the session.

Then I discovered the python koans by Greg Malcolm. By themselves, they are a very good way to learn Python basics and unit testing.

But what would happen if those pykoans respected standard UNIX exit codes and had a basic Travis-CI integration? Indeed, that brings us testing and continuous integration for free!

And then, as a teacher, what if there were easy means to monitor students progress and correct assignments via some API’s and JSON?

The end result is that teaching basic Python along with good programming practices such as TDD and CI is much easier nowadays. Teachers get to help students better without correcting tons of assignments manually and students get green TDD lights as they go.