[TIP] unittest2 plugins

Michael Foord fuzzyman at voidspace.org.uk
Mon Jul 26 08:14:06 PDT 2010


On 26/07/2010 15:52, jason pellerin wrote:
> On Mon, Jul 26, 2010 at 9:58 AM, jason pellerin<jpellerin at gmail.com>  wrote:
>    
>> On Sat, Jul 24, 2010 at 5:39 AM, Michael Foord
>> <fuzzyman at voidspace.org.uk>  wrote:
>>      
>>> On 24/07/2010 09:02, meme dough wrote:
>>>        
>>>> Hi,
>>>>
>>>> I see the email about unittest2 plugins.  I had a play with plugin
>>>> mechanism.
>>>>
>>>>
>>>>          
>>> This is *very* much an experimental work in progress. When it is a bit more
>>> complete I will send an email to python-dev and this list describing the
>>> mechanism and solicit feedback on it.
>>>
>>> For those who just want to play now it is in the "plugins" branch of the
>>> mercurial repo at:
>>>
>>>     http://hg.python.org/unittest2
>>>        
>> This is quite encouraging! I had a look at the branch this weekend,
>> and I can see pretty clearly how to implement most of nose's builtin
>> plugins.
>>      
> Spoke a bit too soon. :) This morning as my first real experiment, I
> tried to implement nose's attribute selector plugin, which lets you
> assign arbitrary attributes to tests and then use commandline switches
> like, eg:
>
> -a !slow
> -a tag=green,red
>
> to filter the tests to run. This turns out to be pretty hard to do
> with the unittest2 plugin api. The hook points for loading tests make
> it easy to add additional tests or totally replace the list of tests
> or test names, but there's no hook for filtering the lists that the
> loader comes up with (or at least I didn't see one). A hook like that
> would be a useful addition, if in fact there isn't one there that I've
> missed.
>    
The getTestCaseNames event is called with the TestCase class and allows 
you to set (or preferably extend) an excludedNames list on the event. 
This will handle tests loaded from test cases.

Note that the system is evolving *rapidly* at the moment. The next 
checkin will include the full test suite in the testRunStart event - so 
filtering could be done there as well.

Something that needs to improve is a way for tests to be uniquely 
identified and methods for them to format their own tracebacks (needed 
for pep8 / pyflakes checkers and doctest loaders etc).

All the best,

Michael




> JP
>    


-- 
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog

READ CAREFULLY. By accepting and reading this email you agree, on behalf of your employer, to release me from all obligations and waivers arising from any and all NON-NEGOTIATED agreements, licenses, terms-of-service, shrinkwrap, clickwrap, browsewrap, confidentiality, non-disclosure, non-compete and acceptable use policies (”BOGUS AGREEMENTS”) that I have entered into with your employer, its partners, licensors, agents and assigns, in perpetuity, without prejudice to my ongoing rights and privileges. You further represent that you have the authority to release me from any BOGUS AGREEMENTS on behalf of your employer.





More information about the testing-in-python mailing list