[TIP] namespace, test vs nosetests, virtualenv

Błażej Cegiełka blazej.cegielka at gmail.com
Thu Aug 13 02:30:39 PDT 2009

Hi all

Let me describe my problem:
i created new virtualenv 'myproj' (in virtualenvs dir)
i created 2 projects as follow (in tmp dir):

|-- lib
|   `-- myproj
|       |-- __init__.py
|       `-- pr2
|           |-- __init__.py
|           |-- module.py
|           `-- tests
|               |-- __init__.py
|               `-- test_module.py
|-- setup.cfg
`-- setup.py

(myproj)[tmp]$ grep namespace MyProjPr2/setup.py

|-- lib
|   `-- myproj
|       |-- __init__.py
|       `-- pr1
|           |-- __init__.py
|           `-- part1
|               |-- __init__.py
|               |-- module.py
|               `-- tests
|                   |-- __init__.py
|                   `-- test_module.py
|-- setup.cfg
`-- setup.py

(myproj)[tmp]$ grep namespace MyProjPr1Part1/setup.py
    namespace_packages=['myproj', 'myproj.pr1'],

and  install_requires=['MyProjPr2',],
namespace_packages as you see.

and now i want test MyProjPr1Part1 (with nosetests).
so first i intalled nose in my 'myproj' virtualenv.
next i tested and builded MyProjPr2 project (without any problems). i don't
installed it in 'myproj' virtualenv.

now it's time to test MyProjPr1Part1 project.
in setup.cfg in [easy_install] section i set find_links to path with
MyProjPr2 egg.
and started nosetests:

(myproj)[MyProjPr1Part1]$ python setup.py nosetests
Checking .pth file support in .
/home/me/virtualenvs/myproj/bin/python -E -c pass
Searching for MyProjPr2
Best match: MyProjPr2 1.1.1
Processing MyProjPr2-1.1.1-py2.5.egg
creating /home/me/tmp/MyProjPr1Part1/MyProjPr2-1.1.1-py2.5.egg
Extracting MyProjPr2-1.1.1-py2.5.egg to /home/me/tmp/MyProjPr1Part1

Installed /home/me/tmp/MyProjPr1Part1/MyProjPr2-1.1.1-py2.5.egg
Failure: ImportError (No module named pr2.module) ... ERROR
Ran 1 test in 0.022s

FAILED (errors=1)

(myproj)[MyProjPr1Part1]$ python setup.py test
Ran 1 test in 0.014s


another tricky thing is that if i declare for MyProjPr2
namespace_package=['myproj', 'pr2',] nosetests will pass.
Could someone explain this behavior for me?

next (light) question is: is there a way to declare a path_to_download for
required eggs. default dir is '.' (current dir)

I put in attachment whole projects structure if somebody would have some fun

Blazej Cegielka
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.idyll.org/pipermail/testing-in-python/attachments/20090813/f69d25ce/attachment.html 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: tmp.tar.gz
Type: application/x-gzip
Size: 1684 bytes
Desc: not available
Url : http://lists.idyll.org/pipermail/testing-in-python/attachments/20090813/f69d25ce/attachment.bin 

More information about the testing-in-python mailing list