[py-dev] New issue 56 in py-trunk: Problems testing modules in namespace package

issues-noreply at bitbucket.org issues-noreply at bitbucket.org
Mon Oct 19 18:14:59 CEST 2009

New issue 56: Problems testing modules in namespace package

cdent on Mon, 19 Oct 2009 18:14:59 +0200:

  When using namespace_packages if I am testing a new module in a namespace that is already installed into sys.path (e.g. an egg in that namespace is already on sys.path) then the new module fails to import when running the test file against py.test.

If I run the same test file with python (and have the test executed) all goes well and the correct code is imported, and the test passes as expected.

While narrowing this down I created a new namespace package and tested it in place (before installing it as an egg). That first test worked fine. I then created a second module in the same namespace and tested it before installing the first module. That tested fine.

I then installed the first module. Subsequent tests of the second module failed.

I'm in Python 2.6.1, py 1.0.2 on OS X 10.6.1

I have attached a tarball which ought to demonstrate this situation.

Inside the tarball are two directories: test.one and test.two. Both contain modules which are destined for the test1234 namespace. As they stand the single test in test dir in each should run just fine. However if 'python setup.py install' is run in the test.one directory, installing test1234.one as egg, the test in test.two will fail to 'from test1234.two import two' (assuming that things don't work).

At first glance this makes me think "oh namespace_packages" are yucky, but if you run 'python test/test_two.py' things work fine...

Happy to do any additional digging about as required. Thanks.

A little more cookbooky on the tarball:

* tar zxvf testme.tar.gz
* cd testme/test.one
* py.test test  # expect success
* cd ../test.two
* py.test test # expect success
* cd ../test.one
* sudo python setup.py install # install egg
* cd ../test.two
* py.test test/test_two.py # except failure "E   ImportError: No module named two"
* python test/test_two.py # expect success

This is an issue notification from bitbucket.org.
You are receiving this either because you are the
owner of the issue, or you are following the issue.

More information about the Pytest-dev mailing list