[TIP] nose2 backwards compatibility questions

Michael Foord fuzzyman at voidspace.org.uk
Sat Aug 14 18:11:09 PDT 2010


On 11/08/2010 15:59, jason pellerin wrote:
> On Wed, Aug 11, 2010 at 10:54 AM, Michael Foord
> <fuzzyman at voidspace.org.uk>  wrote:
>    
>> On 11/08/2010 14:54, jason pellerin wrote:
>>      
>>> Sorry I wasn't able to jump back in yesterday, hectic workday.
>>>
>>> On Tue, Aug 10, 2010 at 2:17 PM, Michael Foord
>>> <fuzzyman at voidspace.org.uk>   wrote:
>>>
>>>        
>>>> On 10/08/2010 14:40, Michael Foord wrote:
>>>>
>>>>          
>>>>> On 09/08/2010 17:49, jason pellerin wrote:
>>>>>
>>>>>            
>>>>>> Some questions for nose2-philes.
>>>>>>
>>>>>> 1) How much do you care about nose-style test discovery? nose does a
>>>>>> bunch of extra work to support real-world package layouts, such as
>>>>>> prepending ./lib and ./src to sys.path
>>>>>>
>>>>>>              
>>>>> This you should still be able to do without issue, right?
>>>>>
>>>>>            
>>>> Ah no, it requires continuing discovery into these directories - with
>>>> them
>>>> as the top level directory - even though they don't contain an
>>>> __init__.py.
>>>> I will propose a fix to the TestLoader that allows this to work.
>>>>
>>>>          
>>> Sounds good. nose's pattern is to actually start discovery in those
>>> directories, if they are present, to ensure that if the project layout
>>> is something like:
>>>
>>> lib/mod.py
>>> tests/tests.py
>>>
>>> that mod is importable from tests.
>>>
>>>        
>> Ok, that sounds straightforward. One question - if there is a lib/ directory
>> *and* a src/ directory do you add both to the path and continue discovery
>> into both of them - or just the first that you find?
>>
>> In some ways allowing both is easier. :-)
>>      
> nose will go into both if it sees both, lib first then src.
>
>    

This has now gone into the unittest2 plugins branch.

It supports the package code being in a 'src' or a 'lib' subdirectory 
(that isn't itself a package). It also supports tests being in any top 
level directory that isn't a package, so long as the directory name 
contains 'test' in it. This is implemented in TestLoader.discover(...). 
These directories (lib, src or the test directories) are added to the 
path and discovery is done in those directories as if they were the top 
level directory.

(So it *doesn't* - but I could add this if it is common - support a 
src/test or lib/test directory that isn't a package.)

All the best,

Michael

>> Great. Sounds like a way forward then. I'll implement this in the
>> TestLoader, using "test*" as the, pattern for finding top level test
>> directories.
>>      
> Great!
>
> 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