views:

36

answers:

1

I have project with the following layout (Python 2.4.3)

root
  +--- src
        +--- xyz
              +--- __init__.py
              +--- C1.py
              +--- C2.py
  +--- test
        +--- xyz
              +--- __init__.py
              +--- CXMock.py
              +--- C1Test.py
              +--- C2Test.py

So i'm writing a unit test (C1Test.py for example) and trying to use CXMock.py there which is only for testing purposes so only in the test area.

But if i try to run that unit test via Eclipse Plugin (PyDev 1.5.4) (python unit-test) i got a message like this:

Finding files...
['/home/.../test/xyz  /C1Test.py.py'] ... done
Importing test modules ... Traceback (most recent call last):
  File "/opt/eclipse-plugins/pydev/plugins/org.python.pydev.debug_1.5.4.2010011921/pysrc/runfiles.py", line 342, in __get_module_from_str
   mod = __import__(modname)
   File "/home/../test/xyz/C1Test.py", line 4, in ?
    from xyz.CXMock.py import CXMock.py
   ImportError: No module named CXMock.py
   ERROR: Module: C1Test could not be imported.
   done.

Does someone has an idea/hint ?

Thanks in advance.

+2  A: 

You don't include the ".py" on your imports. Try:

from xyz.CXMock import CXMock
bstpierre