sort of a beginner question about globals

Duncan Booth duncan.booth at invalid.invalid
Fri Apr 15 10:55:27 EDT 2005


fred.dixon wrote:

>:) unit test is something on my to-learn list. seems involved and i
> haven't seen any straight forward tutorials yet. as yet i still
> consider myself a hobbyist  at best.
> 
Hmm, I believe you are right. I can't see any straight-forward tutorials 
which use Python. I found a tutorial at onlamp.com, but it doesn't seem to 
me to explain TDD at all clearly.

Kent Beck's book is pretty good except that the main tutorial is in Java 
rather than Python, and the Python section tells you how to write a new 
unit test harness (using TDD). So it won't tell you how to use the unittest 
module, but if you use the Python documentation for that (library 
reference, chapter 5.3) you should be able to follow the Java tutorial 
converting it into Python as you go. (Likewise, I've worked through the 
Python chapter converting that into another language when there wasn't a 
suitable xUnit harness available).

It is one of those things that, once you get the hang of it, really grows 
on you: for me the turning point was the first time I added some code and a 
completely unrelated test which had been working fine up until that point, 
and which could not possibly be affected by the latest change, suddenly 
broke. At that point I realised I had just saved myself considerable 
debugging time as without the tests I wouldn't have realised I had 
introduced a problem until much later.



More information about the Python-list mailing list