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.
#python idea (from a student):
@test(inputs=(5,2), output=25)
@test(inputs=(2,5), output=32)
def mypow(base, exp):
return base ** exp
— raymondh (@raymondh) April 25, 2014
In the screencast
I write a decorator that does that from scratch, dicuss "module load"
time, "run" time, the timeit
module and doctest
. Enjoy.