I’m currently trying to get a automatic PyDev/nosetests/GAE setup going in Eclipse, verifying with command-line tinkering. So far, I have something that looks like the following:
Preferences -> PyDev -> PyUnit
Nose Test Runner
Parameters: --with-gae -w "/My/App/Root" --without-sandbox -P
Directory Structure (Normal GAE stuff omitted)
./src/
*module hierarchy*
./tests/
__init__.py
sometests.py
./main.py
./urls.py
At the moment, when I use the same parameters on the command-line in my app root, Python modules within src/ that import ‘main’ or ‘urls’ cause:
ERROR: Failure: ImportError (No module named main)
Note: This is a similar problem as another SO post related to nose. The solution isn’t applicable in this case, as there is no __init__.py in my application root.
For that to work, you’d need to have a structure with 2 pythonpath entries, one adding the ‘src’ and the other adding your project root…
i.e.: Say you have:
/project <- Add this to the PYTHONPATH (i.e. set as source folder in PyDev)
/project/src <- Also add this to the PYTHONPATH (also set as source folder in PyDev)
/project/main.py <- Should now be found as its parent folder is in the PYTHONPATH 🙂
Still, I must say I find that structure a bit awkward… in this use case, I’d probably drop the ‘src’ folder and just leave ‘/project’ in the PYTHONPATH (and move the contents of ‘src’ to the project root)
Or move the ‘main.py’, ‘urls.py’ and ‘tests’ to the ‘src’ folder…