Parallel package hierarchies/directories

atleta atleta.hu at gmail.com
Thu Jan 15 20:51:52 CET 2009


  Hi,

I'd need a logical way to organize my unit tests into packages, but I
don't know how to do it in python. I'd like to separate my test
sources (modules) from the code. The problem is that it seems that
python does not allow a package to spread through multiple
directories. I'd like to have the following layout (which is the usual
way we do it e.g. in java):

+-project_root/
    |
    +-src/
    |   |
    |   +-soap
    |
    +-test/
        |
        +-soap

'soap' is a package under the source tree. I.e. I'd like my test
source tree to mirror the source tree and have package specific tests
in the same package as the code they excersize. However I found that
this is not possible, at least not the way I wanted, not without
moving files. I tried to place a script that would run all tests under
the 'test' directory. It added 'src' to the sys.path, but then it was
only able to import packages from test/soap and not src/soap.

Is there a way I can have python look for soap package modules in both
places? If not, then could someone tell me what is the usual way to
layout test code?

  Thanks,
    atleta



More information about the Python-list mailing list