learning unit testing in python

Josip i.i at i.i
Mon Jun 23 15:26:25 EDT 2008


> Hi all.
>
> I'd like learn some basic unit testing with python.
> I red some articles about different testing framework like unittest or
> nose, but I'm a bit confused: what is the best choice? I'm not a
> professional developer (I'm a SEO) but I belive that unit testing is a
> good and pragmatic way to produce working software, so I'd like to
> find something really simple ad straightforward because I don't have
> to manage big programming projects.
>
> Thanks in advance,
>
> Alex

Have you checked out doctest?
http://docs.python.org/lib/module-doctest.html
It's the best way to add few tests to function or class, you just add
them to docstring.
Unit tests are somewhat demanding as they usualy require creating another
file just for storing them, but are ofcourse more powerful as well. For 
example,
unittest module alows you to execute a section of code before or after each 
test
to initialize values and clean up.

Nose module has few extra features, but it can also run test writen for 
unittest,
so it's easy to switch if you find standard library module lacking for your 
purpose. 





More information about the Python-list mailing list