Hairy Sun

Matt's Blog on Some Geeky Topics

Using Decorators for Testing Screencast

I made a screencast exploring one of Raymond Hettinger’s tweets a while back. His 140 character exposition suggested that a student of his wanted to use decorators to unittest functions.

In the screencast I write a decorator that does that from scratch, dicuss “module load” time, “run” time, the timeit module and doctest. Enjoy.

Can decorators be used to test functions? How? Why would you do this? Why not?