GAMR1520: Markup languages and scripting

python logo

Week 4: Unit testing

Back to home

This week is the final week of python. The focus is on unit testing in preparation for the python assignment. Unit tests allow us to write code that acts as a specification for how other code should behave. With unit tests, we can automatically test whether our code produces given outputs when given certain inputs. This not only allows us to know whether code is working, it also highlights places where we introduce bugs.

Lectures

Lab exercises

Lab 4.1: Unit testing with python

Unit tests allow us to create a specification for functions and to test whether the function does what we want it to do under various circumstances. For example, we can put different data into a function and confirm that the output is what we want.