[TIP] nose2 backwards compatibility questions

Kumar McMillan kumar.mcmillan at gmail.com
Wed Aug 11 09:40:00 PDT 2010


On Wed, Aug 11, 2010 at 11:14 AM, Michael Foord
<fuzzyman at voidspace.org.uk> wrote:
>> I'd rather see the developer take responsibility for putting lib and
>> src dirs on their sys.path.
>
> It isn't just a question of adding directories to sys.path - test discovery
> has to happen in these directories using the right directory as the "top
> level" of the project for turning paths into importable names.
>
> The question is also one of supporting common project layouts "out of the
> box", so making it controllable is one thing and the default behaviour is
> another...

ohh, I missed the part about descending into lib/src dirs to look for
tests ;)  Carry on.

>
> (I'm a big fan of tox by the way - unittest2 itself is tested with tox.)
>
> Michael
>
>> It's as simple as this (in Nose):
>>
>> class MyTestLayout(Plugin):
>>     ...
>>     def begin(self):
>>         sys.path.extend(['lib','src'])
>>
>> nose.main(addplugins=[MyTestLayout()], ...)
>>
>>
>> Furthermore, I think something like tox [1] encourages a much better
>> practice whereby before any tests are run your module(s) under test
>> are installed just like they would be in real life.  You also can
>> specify any external modules to install that are specific to your test
>> suite (and not your production code).
>>
>> [1] http://codespeak.net/tox/
>>
>> -Kumar
>>
>
>
> --
> 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