1

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.

Community
  • 1
  • 1
PastryExplosion
  • 703
  • 4
  • 12

1 Answers1

1

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...

Fabio Zadrozny
  • 24,814
  • 4
  • 66
  • 78
  • Refactoring aside, I had completely taken for granted that GAE was setting the app directory on the PYTHONPATH for me on deploy. Fixing my Eclipse setup was definitely the problem. I do agree on src/ though. But one step at a time. – PastryExplosion Mar 08 '12 at 00:27