Issue #240 resolved

Namespace packages (python 3.3) support

1st1 avatar1st1 created an issue

Currently there is a bug (latest py & pytest, python 3.3) with support of new namespace packages. Attached please find an example project. Please unpack it, Add top-level 'foo' dir to your 'PYTHONPATH', then 'cd' to the top-level foo and execute 'py.test -s'.

The bug is that 'foo' is a namespace package (i.e. doesn't have an '' file) and in this case, pytest loads '' package TWO times, first as 'bar.spam' and secondly as ''.

This happens because py.path.local.LocalPath.pypkgpath explicitly checks for '' files in packages, which fails for new namespaces semantics.

Comments (13)

  1. 1st1

    Just attached a couple of patches on pylib and pytest. Patch to pylib is probably not an ideal one, but it at least fixes this particular bug with running tests from a top-level namespace package,

  2. holger krekel

    on first look i think they are ok. I think the ns1 patch should be a bit extended - to also cover the case discussed on the ML (see link above), namely also a dir containing an can be in sys.path. When writing tests we can see if all cases are covered. (there already is a test for pyimport so adding a few more shouldn't be hard).

  3. 1st1

    Hi Holger,

    I guess I don't have enough time to review them now, as we switched away from py.test to our custom testing framework. I can send you our "import_path" code, that works with 3.3 and namespace packages, it's more or less refined and battle-tested now.

  4. holger krekel

    close issue240 - rework "good practises" document and discuss discuss the two common test directory layouts in more detail, including an explicit note on how it interacts with PEP420-namespace packages.

    → <<cset 23152b79f1dc>>

  5. Log in to comment
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.