Unification of logging in Python's Standard Library

Duncan Booth duncan at NOSPAMrcp.co.uk
Wed Aug 20 04:57:58 EDT 2003


"John Roth" <newsgroups at jhrothjr.com> wrote in 
news:vk5kc9g9uqj038 at news.supernews.com:

>> I will say that unittest is what motivated me to suggest this in the
>> first place, since I'm working on a testing framework that is
>> attempting to take advantage of both the unittest *and* logging
>> modules.  Perhaps a new TestRunner class that uses logging
>> (LoggingTestRunner?) might coexist with the default TextTestRunner.
> 
> Perhaps you could tell us a bit more about this? My usage of
> unittest is (relatively) pure XP/TDD - I expect all of the tests
> to pass except the last one I worked on, and when they don't,
> I swat it immediately. Consequently, I don't see any need for
> logging anything.
> 

I would find it interesting, and possibly even useful, if unittest could be 
made to record some historical information in a database. e.g. The date and 
time when each unit test first failed, first passed, and most recently 
failed/passed, and the number of times each test has passed/failed. A 
record of the #lines of code each time the tests all pass would also be 
useful, and you probably want to record the stats separately against each 
developer.

On a project with several developers (or one undisciplined one like myself) 
you could potentially use these figures to flag problems, such as someone 
whose tests usually pass first time is probably doing test last rather than 
test first coding, or if a lot of new code appears without new tests it was 
either a major refactor or someone isn't writing the tests they need.
Someone who is doing it properly will show a pattern of at least three test 
runs (one fail, two passes) for each new test. Finally, should you survive 
lynching by the developers, the customer will be really pleased to see 
complicated graphs showing how much testing you are doing.

Of course, this is completely unrelated to the sort of logging the logging 
module could do for you.

-- 
Duncan Booth                                             duncan at rcp.co.uk
int month(char *p){return(124864/((p[0]+p[1]-p[2]&0x1f)+1)%12)["\5\x8\3"
"\6\7\xb\1\x9\xa\2\0\4"];} // Who said my code was obscure?




More information about the Python-list mailing list