[TIP] Unittest Changes

Michael Foord fuzzyman at voidspace.org.uk
Mon Jul 21 06:29:59 PDT 2008


Nicolas Chauvat wrote:
> Hi, 
>
> On Sun, Jul 20, 2008 at 10:16:43PM +0100, Michael Foord wrote:
>   
>> The biggest way I can think of improving unittest is to add automatic 
>> test discovery:
>>
>>     unittests.discover_tests(path='.', pattern='test*.py', recurse=True)
>>
>> This will simply search the path provided (defaulting to the current 
>> directory) matching test files based on the pattern.
>>
>> With appropriate changes to unittest when run as __main__ so that you 
>> can do:
>>
>>      python -m unittest [<directory> [<filter>]]
>>
>> Along with this a 'run_tests' function that takes any number of modules, 
>> test cases and test suites and consolidates them into a single test 
>> suite and runs them (defaulting to use TextTestRunner).
>>
>> Another change will be the improvement of failure message for 
>> assertEquals. When comparing long strings it will show a diff, when 
>> comparing containers it will show you the members that are different 
>> (lists, sets, dictionaries).
>>     
>
> We already have code that does this on top of unittest.
>   

Same at Resolver Systems. :-)

Although I doubt I can open source our code, so when I come to it I'll 
take a look at yours first.

Thanks!

Michael
> It is part of the logilab.common library. The command is named pytest
> and the extension to TestCase is logilab.common.testlib.TestCase. We
> have been writing our tests with this since before the nose project
> started and never had the time to see what could be merged or if
> replacing our stuff with nose would be a better option.
>
> If you want (parts of) it, it is yours. Since we had no contribution
> to this code, if you tell us that your aim is to put the code in the
> standard library and ask us, we may even change its license (at the
> moment, this is GPL).
>
> http://www.logilab.org/cgi-bin/hgwebdir.cgi/logilab/common/file/d1162ce2e196/pytest.py
> http://www.logilab.org/cgi-bin/hgwebdir.cgi/logilab/common/file/d1162ce2e196/testlib.py
> http://www.logilab.org/project/logilab-common
>
> Hope this helps,
>
>   


-- 
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/
http://www.trypython.org/
http://www.ironpython.info/
http://www.resolverhacks.net/
http://www.theotherdelia.co.uk/




More information about the testing-in-python mailing list