That function would be used from each test file. So supposing that
were added to i.e. py.path, then you have to add in each test file:

import py
py.path.import_local()

And then you can access to you source files without installing them.

Here is more clear about how is used:
http://bitbucket.org/ares/scripy/src/f4dcdf53cba6/test/test_scripy/test_system.py

It lets import the packages under 'lib':
http://bitbucket.org/ares/scripy/src/f4dcdf53cba6/lib/

The great advantage is that you have not to run 'python setup.py
develop' every time that you change your source files so it's very
helpfull during development and testing.


2009/12/23 holger krekel <hol...@merlinux.eu>:
> On Wed, Dec 23, 2009 at 13:28 +0000, Joan Miller wrote:
>> I'm using the next function to access to the source from tests without
>> install it (python setup.py develop). It's very usefull during
>> development so it could be added to py.
>
> If you use 'python setup.py develop' you should be able to
> import your package that you are currently working on already.
>
> Can you post an example how and from which file you use
> the posted function?
>
> cheers,
> holger
>
>
>> ------------------------
>> import os
>> import sys
>>
>> def import_local(parent='test', child='lib'):
>>     """Inserts local library on 'sys.path'.
>>
>>     Goes up until the root of the project (upper of 'parent' directory)
>>     and inserts the 'child' directory.
>>     """
>>     parent_path = os.path.abspath(os.path.dirname(__file__))
>>
>>     while parent in os.path.basename(parent_path):
>>         parent_path = os.path.dirname(parent_path)
>>
>>     sys.path.insert(0, os.path.join(parent_path, child))
>> ------------------------
>> _______________________________________________
>> py-dev mailing list
>> py-dev@codespeak.net
>> http://codespeak.net/mailman/listinfo/py-dev
>>
>
> --
>
_______________________________________________
py-dev mailing list
py-dev@codespeak.net
http://codespeak.net/mailman/listinfo/py-dev

Reply via email to