[Tutor] Unit-testing advice

C.T. Matsumoto c.t.matsumoto at gmail.com
Mon Mar 8 09:43:14 CET 2010


mhw at doctors.net.uk wrote:
> Dear All,
> 
> Quick UT question. I am working on a CSV processing script. I want to write some tests. The tests will need to read in, manipulate and write out some CSV files. 
> 
> My instinct is to manually construct some small data files, and consider them as part of the test suite. The other option would be to programatically construct them (? As a set-up).
> 
> Which is better? 
> 
> Thanks,
> 
> Matt
> 
> 
> Sent from my BlackBerry® wireless device
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> http://mail.python.org/mailman/listinfo/tutor
> 
I guess this depends on what part of your program you are testing.

If you are testing small 'nuts and bolts' part of the script I usually 
have the test data written into the test as global variables.

As your functionality becomes more complete, you probably need to switch 
to importing a test data file.

I agree I'd manually construct some data files. But if you want to test 
directory/file creation you could programaticaly create a test directory 
in /tmp/ to test on.

T


More information about the Tutor mailing list